X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FXfer%2FRsync.pm;h=9612cab634757a5c99339b927048032d10446dbe;hp=d033798c252f8aa76b7ce769535eccf44d2e808c;hb=e951f787a66c5bd9e9955c3f657a5b44289c0fe1;hpb=2c14784ad71874ec850d189060fe63d6eb9eba95 diff --git a/lib/BackupPC/Xfer/Rsync.pm b/lib/BackupPC/Xfer/Rsync.pm index d033798..9612cab 100644 --- a/lib/BackupPC/Xfer/Rsync.pm +++ b/lib/BackupPC/Xfer/Rsync.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 8 Feb 2004. +# Version 2.1.0, released 20 Jun 2004. # # See http://backuppc.sourceforge.net. # @@ -52,9 +52,12 @@ BEGIN { $RsyncLibOK = 0; $RsyncLibErr = "File::RsyncP module doesn't exist"; } else { - if ( $File::RsyncP::VERSION < 0.44 ) { + # + # Note: also update configure.pl when this version number is changed! + # + if ( $File::RsyncP::VERSION < 0.51 ) { $RsyncLibOK = 0; - $RsyncLibErr = "File::RsyncP module version too old: need 0.44"; + $RsyncLibErr = "File::RsyncP module version too old: need 0.50"; } else { $RsyncLibOK = 1; } @@ -138,24 +141,11 @@ sub start } else { # # Turn $conf->{BackupFilesOnly} and $conf->{BackupFilesExclude} - # into a hash of arrays of files. + # into a hash of arrays of files, and $conf->{RsyncShareName} + # to an array # - $conf->{RsyncShareName} = [ $conf->{RsyncShareName} ] - unless ref($conf->{RsyncShareName}) eq "ARRAY"; - foreach my $param qw(BackupFilesOnly BackupFilesExclude) { - next if ( !defined($conf->{$param}) ); - if ( ref($conf->{$param}) eq "ARRAY" ) { - $conf->{$param} = { - $conf->{RsyncShareName}[0] => $conf->{$param} - }; - } elsif ( ref($conf->{$param}) eq "HASH" ) { - # do nothing - } else { - $conf->{$param} = { - $conf->{RsyncShareName}[0] => [ $conf->{$param} ] - }; - } - } + $bpc->backupFileConfFix($conf, "RsyncShareName"); + if ( defined($conf->{BackupFilesOnly}{$t->{shareName}}) ) { my(@inc, @exc, %incDone, %excDone); foreach my $file ( @{$conf->{BackupFilesOnly}{$t->{shareName}}} ) { @@ -222,7 +212,12 @@ sub start } } if ( $t->{type} eq "full" ) { - $logMsg = "full backup started for directory $t->{shareName}"; + if ( $t->{partialNum} ) { + $logMsg = "full backup started for directory $t->{shareName};" + . " updating partial $t->{partialNum}"; + } else { + $logMsg = "full backup started for directory $t->{shareName}"; + } } else { $incrDate = $bpc->timeStamp($t->{lastFull} - 3600, 1); $logMsg = "incr backup started back to $incrDate for directory" @@ -273,7 +268,7 @@ sub start # $t->{rsyncClientCmd} = $rsyncClientCmd; $t->{rs} = File::RsyncP->new({ - logLevel => $conf->{RsyncLogLevel}, + logLevel => $t->{logLevel} || $conf->{RsyncLogLevel}, rsyncCmd => sub { $bpc->verbose(0); $bpc->cmdExecOrEval($rsyncClientCmd, $args); @@ -281,11 +276,26 @@ sub start rsyncCmdType => "full", rsyncArgs => $rsyncArgs, timeout => $conf->{ClientTimeout}, - logHandler => sub { - my($str) = @_; - $str .= "\n"; - $t->{XferLOG}->write(\$str); - }, + doPartial => defined($t->{partialNum}) ? 1 : undef, + logHandler => + sub { + my($str) = @_; + $str .= "\n"; + $t->{XferLOG}->write(\$str); + if ( $str =~ /^Remote\[1\]: read errors mapping "(.*)"/ ) { + # + # Files with read errors (eg: region locked files + # on WinXX) are filled with 0 by rsync. Remember + # them and delete them later. + # + my $badFile = $1; + $badFile =~ s/^\/+//; + push(@{$t->{badFiles}}, { + share => $t->{shareName}, + file => $badFile + }); + } + }, pidHandler => sub { $t->{pidHandler}(@_); }, @@ -294,12 +304,14 @@ sub start bpc => $t->{bpc}, conf => $t->{conf}, backups => $t->{backups}, - logLevel => $conf->{RsyncLogLevel}, + logLevel => $t->{logLevel} + || $conf->{RsyncLogLevel}, logHandler => sub { my($str) = @_; $str .= "\n"; $t->{XferLOG}->write(\$str); }, + cacheCheckProb => $conf->{RsyncCsumCacheVerifyProb}, %$fioArgs, }), }); @@ -421,6 +433,15 @@ sub run } } +sub abort +{ + my($t, $reason) = @_; + my $rs = $t->{rs}; + + $rs->abort($reason); + return 1; +} + sub setSelectMask { my($t, $FDreadRef) = @_;