Changeset 119

Show
Ignore:
Timestamp:
04/14/10 17:35:20 (4 years ago)
Author:
depesz
Message:

add handling of dst-backup - non fatal, not-compressible, local destination

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/omnipitr/lib/OmniPITR/Program/Archive.pm

    r116 r119  
    6161 
    6262            my $destination_file_path = $dst->{ 'path' }; 
     63            my $is_backup = ( $dst->{ 'path' } eq $self->{ 'dst-backup' } ); 
    6364            $destination_file_path =~ s{/*\z}{}; 
    6465            $destination_file_path .= '/' . basename( $local_file ); 
     
    7172 
    7273            if ( $response->{ 'error_code' } ) { 
    73                 $self->log->fatal( "Cannot send segment %s to %s : %s", $local_file, $destination_file_path, $response ); 
     74                if ( $is_backup ) { 
     75                    $self->log->error( "Sending segment %s to backup destination %s generated (ignored) error: %s", $local_file, $destination_file_path, $response ); 
     76                } 
     77                else { 
     78                    $self->log->fatal( "Cannot send segment %s to %s : %s", $local_file, $destination_file_path, $response ); 
     79                } 
    7480            } 
    7581            $self->{ 'state' }->{ 'sent' }->{ $destination_type }->{ $dst->{ 'path' } } = 1; 
     
    291297        'bzip2-path|bp=s', 
    292298        'data-dir|D=s', 
     299        'dst-backup|db=s', 
    293300        'dst-local|dl=s@', 
    294301        'dst-remote|dr=s@', 
     
    306313    $args{ 'log' } =~ tr/^/%/; 
    307314 
    308     for my $key ( qw( data-dir temp-dir state-dir pid-file verbose gzip-path bzip2-path lzma-path force-data-dir ) ) { 
     315    for my $key ( qw( data-dir dst-backup temp-dir state-dir pid-file verbose gzip-path bzip2-path lzma-path force-data-dir ) ) { 
    309316        $self->{ $key } = $args{ $key }; 
    310317    } 
     
    360367    } 
    361368 
     369    if ( $self->{ 'dst-backup' } ) { 
     370        if ( $self->{ 'dst-backup' } =~ m{\A(gzip|bzip2|lzma)=} ) { 
     371            $self->log->fatal( 'dst-backup cannot be compressed! [%]', $self->{ 'dst-backup' } ); 
     372        } 
     373        unless ( $self->{ 'dst-backup' } =~ m{\A/} ) { 
     374            $self->log->fatal( 'dst-backup has to be absolute path, and it is not: %s', $self->{ 'dst-backup' } ); 
     375        } 
     376        if ( -e $self->{ 'dst-backup' } ) { 
     377            push @{ $self->{ 'destination' }->{ 'local' } }, 
     378                { 
     379                'compression' => 'none', 
     380                'path'        => $self->{ 'destination' }->{ 'local' }, 
     381                }; 
     382        } 
     383    } 
     384 
    362385    my $dst_count = scalar( @{ $self->{ 'destination' }->{ 'local' } } ) + scalar( @{ $self->{ 'destination' }->{ 'remote' } } ); 
    363386    $self->log->fatal( "No --dst-* has been provided!" ) if 0 == $dst_count;