X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FXfer%2FRsync.pm;h=5f5f3a38e4d6aa0595f007e42e49444751306338;hp=d3358c972d6a718c56b8210da2d026694c769158;hb=31a7aca27ffd75e0aee9836704599cdb95dc2421;hpb=1a2fa2c2a1e0db12dc788216d9f3ba73301a131f diff --git a/lib/BackupPC/Xfer/Rsync.pm b/lib/BackupPC/Xfer/Rsync.pm index d3358c9..5f5f3a3 100644 --- a/lib/BackupPC/Xfer/Rsync.pm +++ b/lib/BackupPC/Xfer/Rsync.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0beta2, released 9 May 2004. +# Version 3.0.0beta2, released 11 Nov 2006. # # See http://backuppc.sourceforge.net. # @@ -40,6 +40,7 @@ package BackupPC::Xfer::Rsync; use strict; use BackupPC::View; use BackupPC::Xfer::RsyncFileIO; +use Encode qw/from_to encode/; use vars qw( $RsyncLibOK $RsyncLibErr ); @@ -55,9 +56,10 @@ BEGIN { # # Note: also update configure.pl when this version number is changed! # - if ( $File::RsyncP::VERSION < 0.51 ) { + if ( $File::RsyncP::VERSION < 0.68 ) { $RsyncLibOK = 0; - $RsyncLibErr = "File::RsyncP module version too old: need 0.50"; + $RsyncLibErr = "File::RsyncP module version" + . " ($File::RsyncP::VERSION) too old: need 0.68"; } else { $RsyncLibOK = 1; } @@ -129,6 +131,8 @@ sub start $rsyncArgs = $conf->{RsyncRestoreArgs}; my $remoteDir = "$t->{shareName}/$t->{pathHdrDest}"; $remoteDir =~ s{//+}{/}g; + from_to($remoteDir, "utf8", $conf->{ClientCharset}) + if ( $conf->{ClientCharset} ne "" ); $argList = ['--server', @$rsyncArgs, '.', $remoteDir]; $fioArgs = { client => $t->{bkupSrcHost}, @@ -141,24 +145,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}}} ) { @@ -209,9 +200,13 @@ sub start } } foreach my $file ( @inc ) { + $file = encode($conf->{ClientCharset}, $file) + if ( $conf->{ClientCharset} ne "" ); push(@fileList, "--include=$file"); } foreach my $file ( @exc ) { + $file = encode($conf->{ClientCharset}, $file) + if ( $conf->{ClientCharset} ne "" ); push(@fileList, "--exclude=$file"); } } @@ -221,19 +216,25 @@ sub start # # just append additional exclude lists onto the end # + $file = encode($conf->{ClientCharset}, $file) + if ( $conf->{ClientCharset} ne "" ); push(@fileList, "--exclude=$file"); } } if ( $t->{type} eq "full" ) { if ( $t->{partialNum} ) { $logMsg = "full backup started for directory $t->{shareName};" - . " updating partial $t->{partialNum}"; + . " updating partial #$t->{partialNum}"; } else { $logMsg = "full backup started for directory $t->{shareName}"; + if ( $t->{incrBaseBkupNum} ne "" ) { + $logMsg .= " (baseline backup #$t->{incrBaseBkupNum})"; + } } } else { - $incrDate = $bpc->timeStamp($t->{lastFull} - 3600, 1); - $logMsg = "incr backup started back to $incrDate for directory" + $incrDate = $bpc->timeStamp($t->{incrBaseTime}, 1); + $logMsg = "incr backup started back to $incrDate" + . " (backup #$t->{incrBaseBkupNum}) for directory" . " $t->{shareName}"; } @@ -249,12 +250,18 @@ sub start $rsyncArgs = [@$rsyncArgs, "--ignore-times"] if ( $t->{type} eq "full" ); $rsyncClientCmd = $conf->{RsyncClientCmd}; + my $shareNameSlash = $t->{shareNameSlash}; + from_to($shareNameSlash, "utf8", $conf->{ClientCharset}) + if ( $conf->{ClientCharset} ne "" ); $argList = ['--server', '--sender', @$rsyncArgs, - '.', $t->{shareNameSlash}]; + '.', $shareNameSlash]; + eval { + $argList = File::RsyncP->excludeStrip($argList); + }; $fioArgs = { client => $t->{client}, share => $t->{shareName}, - viewNum => $t->{lastFullBkupNum}, + viewNum => $t->{incrBaseBkupNum}, partialNum => $t->{partialNum}, }; } @@ -272,6 +279,10 @@ sub start sshPath => $conf->{SshPath}, argList => $argList, }; + from_to($args->{shareName}, "utf8", $conf->{ClientCharset}) + if ( $conf->{ClientCharset} ne "" ); + from_to($args->{shareNameSlash}, "utf8", $conf->{ClientCharset}) + if ( $conf->{ClientCharset} ne "" ); $rsyncClientCmd = $bpc->cmdVarSubstitute($rsyncClientCmd, $args); # @@ -312,6 +323,7 @@ sub start pidHandler => sub { $t->{pidHandler}(@_); }, + clientCharset => $conf->{ClientCharset}, fio => BackupPC::Xfer::RsyncFileIO->new({ xfer => $t, bpc => $t->{bpc}, @@ -325,6 +337,7 @@ sub start $t->{XferLOG}->write(\$str); }, cacheCheckProb => $conf->{RsyncCsumCacheVerifyProb}, + clientCharset => $conf->{ClientCharset}, %$fioArgs, }), }); @@ -354,6 +367,11 @@ sub run $remoteDir = $t->{shareNameSlash}; $remoteDirDaemon = "."; } + from_to($remoteDir, "utf8", $conf->{ClientCharset}) + if ( $conf->{ClientCharset} ne "" ); + from_to($remoteDirDaemon, "utf8", $conf->{ClientCharset}) + if ( $conf->{ClientCharset} ne "" ); + if ( $t->{XferMethod} eq "rsync" ) { # # Run rsync command @@ -361,6 +379,8 @@ sub run my $str = "Running: " . $t->{bpc}->execCmd2ShellCmd(@{$t->{rsyncClientCmd}}) . "\n"; + from_to($str, $conf->{ClientCharset}, "utf8") + if ( $conf->{ClientCharset} ne "" ); $t->{XferLOG}->write(\$str); $rs->remoteStart($remoteSend, $remoteDir); } else { @@ -381,6 +401,8 @@ sub run # my $module = $t->{shareName}; $module = $t->{shareNameSlash} if ( $module =~ /\// ); + from_to($module, "utf8", $conf->{ClientCharset}) + if ( $conf->{ClientCharset} ne "" ); if ( defined(my $err = $rs->serverService($module, $conf->{RsyncdUserName}, $conf->{RsyncdPasswd}, @@ -393,7 +415,10 @@ sub run } $rs->serverStart($remoteSend, $remoteDirDaemon); } - my $error = $rs->go($t->{shareNameSlash}); + my $shareNameSlash = $t->{shareNameSlash}; + from_to($shareNameSlash, "utf8", $conf->{ClientCharset}) + if ( $conf->{ClientCharset} ne "" ); + my $error = $rs->go($shareNameSlash); $rs->serverClose(); #