Changeset 172

Show
Ignore:
Timestamp:
06/28/10 19:47:43 (4 years ago)
Author:
depesz
Message:

fix multiple --transform options to tar

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/omnipitr/doc/changes.pod

    r171 r172  
    22 
    33=head2 2010-06-28 
     4 
     5=over 
     6 
     7=item * Fix type in changelog (28 -> 23) 
     8 
     9=item * Fix call to tar with 2 --transform options. Some tar versions don't 
     10handle it well, and it's required for omnipitr-backup-slave 
     11 
     12=back 
     13 
     14=head2 2010-06-23 
    415 
    516=over 
  • trunk/omnipitr/lib/OmniPITR/Program/Backup/Slave.pm

    r171 r172  
    139139    $source_transform_from =~ s{^/*}{}; 
    140140    $source_transform_from =~ s{/*$}{}; 
    141     my $source_transform_to = basename( $self->{ 'data-dir' } ) . '/pg_xlog'; 
    142     my $source_transform_command = sprintf 's#^%s#%s#', $source_transform_from, $source_transform_to; 
    143  
    144     my $dot_backup_transform_from = File::Spec->catfile( $self->{ 'temp-dir' }, $self->{ 'dot_backup_filename' } ); 
     141 
     142    my $dot_backup_transform_from = $self->{ 'temp-dir' }; 
    145143    $dot_backup_transform_from =~ s{^/*}{}; 
    146144    $dot_backup_transform_from =~ s{/*$}{}; 
    147     my $dot_backup_transform_to = basename( $self->{ 'data-dir' } ) . '/pg_xlog/' . $self->{ 'dot_backup_filename' }; 
    148     my $dot_backup_transform_command = sprintf 's#^%s#%s#', $dot_backup_transform_from, $dot_backup_transform_to; 
     145 
     146    my $transform_to = basename( $self->{ 'data-dir' } ) . '/pg_xlog'; 
     147    my $transform_command = sprintf 's#^\(%s\|%s\)#%s#', $source_transform_from, $dot_backup_transform_from, $transform_to; 
    149148 
    150149    $self->tar_and_compress( 
    151         'work_dir' => dirname( $self->{'source'}->{'path'} ), 
    152         'tar_dir'  => [ basename( $self->{ 'source' }->{ 'path' } ), File::Spec->catfile( $self->{ 'temp-dir' }, $self->{ 'dot_backup_filename' } ), ], 
    153         'transform' => [ $source_transform_command, $dot_backup_transform_command ], 
     150        'work_dir' => dirname( $self->{ 'source' }->{ 'path' } ), 
     151        'tar_dir'  => [ basename( $self->{ 'source' }->{ 'path' } ), File::Spec->catfile( $self->{ 'temp-dir' }, $self->{ 'dot_backup_filename' } ), ], 
     152        'transform' => [ $transform_command ], 
    154153    ); 
    155154 
     
    180179        my $new_file = File::Spec->catfile( $new_source, $segment ); 
    181180        copy( $old_file, $new_file ) or $self->log->fatal( 'Cannot copy %s to %s: %s', $old_file, $new_file, $OS_ERROR ); 
    182         $self->log->log('File copied: %s -> %s', $old_file, $new_file); 
    183         my $response = run_command( $self->{ 'temp-dir' }, $self->{ 'nice-path' }, $self->{ $self->{'source'}->{'compression'} . '-path' }, '-d', $new_file ); 
     181        $self->log->log( 'File copied: %s -> %s', $old_file, $new_file ); 
     182        my $response = run_command( $self->{ 'temp-dir' }, $self->{ 'nice-path' }, $self->{ $self->{ 'source' }->{ 'compression' } . '-path' }, '-d', $new_file ); 
    184183        if ( $response->{ 'error_code' } ) { 
    185184            $self->log->fatal( 'Error while uncompressing wal segment %s: %s', $new_file, $response ); 
     
    734733    $self->log->fatal( "Filename template cannot contain / or \\ characters!" ) if $self->{ 'filename-template' } =~ m{[/\\]}; 
    735734 
    736     $self->log->fatal( 'Source of WAL files was not provided!' ) unless defined $self->{ 'source' }
     735    $self->log->fatal( 'Source of WAL files was not provided!' ) unless defined $self->{ 'source' }->{ 'path' }
    737736    $self->log->fatal( 'Provided source of wal files (%s) does not exist!',   $self->{ 'source' }->{ 'path' } ) unless -e $self->{ 'source' }->{ 'path' }; 
    738737    $self->log->fatal( 'Provided source of wal files (%s) is not directory!', $self->{ 'source' }->{ 'path' } ) unless -d $self->{ 'source' }->{ 'path' };