X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FXfer%2FSmb.pm;h=3a68d144f33610cd41622f8dbd3a04b6825b9050;hp=3d6dd5278070de8afde323b901170ee455bf58e9;hb=b81d2da5e16975674f011e4833337ac0fa24e0ea;hpb=d6dd48e6594d937dea49e3dd1c5ddaba6719df0d diff --git a/lib/BackupPC/Xfer/Smb.pm b/lib/BackupPC/Xfer/Smb.pm index 3d6dd52..3a68d14 100644 --- a/lib/BackupPC/Xfer/Smb.pm +++ b/lib/BackupPC/Xfer/Smb.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 13 Mar 2004. +# Version 3.0.0beta2, released 11 Nov 2006. # # See http://backuppc.sourceforge.net. # @@ -38,6 +38,7 @@ package BackupPC::Xfer::Smb; use strict; +use Encode qw/from_to encode/; sub new { @@ -103,33 +104,24 @@ 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->{SmbShareName} + # to an array # - $conf->{SmbShareName} = [ $conf->{SmbShareName} ] - unless ref($conf->{SmbShareName}) eq "ARRAY"; - foreach my $param qw(BackupFilesOnly BackupFilesExclude) { - next if ( !defined($conf->{$param}) ); - if ( ref($conf->{$param}) eq "ARRAY" ) { - $conf->{$param} = { - $conf->{SmbShareName}[0] => $conf->{$param} - }; - } elsif ( ref($conf->{$param}) eq "HASH" ) { - # do nothing - } else { - $conf->{$param} = { - $conf->{SmbShareName}[0] => [ $conf->{$param} ] - }; - } - } + $bpc->backupFileConfFix($conf, "SmbShareName"); + $t->{fileIncludeHash} = {}; if ( defined($conf->{BackupFilesOnly}{$t->{shareName}}) ) { foreach my $file ( @{$conf->{BackupFilesOnly}{$t->{shareName}}} ) { + $file = encode($conf->{ClientCharset}, $file) + if ( $conf->{ClientCharset} ne "" ); push(@fileList, $file); $t->{fileIncludeHash}{$file} = 1; } } elsif ( defined($conf->{BackupFilesExclude}{$t->{shareName}}) ) { foreach my $file ( @{$conf->{BackupFilesExclude}{$t->{shareName}}} ) { + $file = encode($conf->{ClientCharset}, $file) + if ( $conf->{ClientCharset} ne "" ); push(@fileList, $file); } # @@ -143,11 +135,13 @@ sub start } else { $timeStampFile = "$t->{outDir}/timeStamp.level0"; open(LEV0, ">", $timeStampFile) && close(LEV0); - utime($t->{lastFull} - 3600, $t->{lastFull} - 3600, $timeStampFile); + utime($t->{incrBaseTime} - 3600, $t->{incrBaseTime} - 3600, + $timeStampFile); $smbClientCmd = $conf->{SmbClientIncrCmd}; $logMsg = "incr backup started back to " - . $bpc->timeStamp($t->{lastFull} - 3600, 0) - . "for share $t->{shareName}"; + . $bpc->timeStamp($t->{incrBaseTime} - 3600, 0) + . " (backup #$t->{incrBaseBkupNum}) for share" + . " $t->{shareName}"; } } my $args = { @@ -162,6 +156,8 @@ sub start X_option => $X_option, timeStampFile => $timeStampFile, }; + from_to($args->{shareName}, "utf8", $conf->{ClientCharset}) + if ( $conf->{ClientCharset} ne "" ); $smbClientCmd = $bpc->cmdVarSubstitute($smbClientCmd, $args); if ( !defined($t->{xferPid} = open(SMB, "-|")) ) { @@ -204,6 +200,8 @@ sub start return; } my $str = "Running: " . $bpc->execCmd2ShellCmd(@$smbClientCmd) . "\n"; + from_to($str, $conf->{ClientCharset}, "utf8") + if ( $conf->{ClientCharset} ne "" ); $t->{XferLOG}->write(\$str); alarm($conf->{ClientTimeout}); $t->{_errStr} = undef; @@ -240,6 +238,9 @@ sub readOutput # alarm($conf->{ClientTimeout}) if ( !$t->{abort} ); $t->{lastOutputLine} = $_ if ( !/^$/ ); + + from_to($_, $conf->{ClientCharset}, "utf8") + if ( $conf->{ClientCharset} ne "" ); # # This section is highly dependent on the version of smbclient. # If you upgrade Samba, make sure that these regexp are still valid. @@ -274,6 +275,7 @@ sub readOutput || /^\s*Call timed out: server did not respond/i || /^\s*tree connect failed: ERRDOS - ERRnoaccess \(Access denied\.\)/ || /^\s*tree connect failed: NT_STATUS_BAD_NETWORK_NAME/ + || /^\s*NT_STATUS_INSUFF_SERVER_RESOURCES listing / ) { if ( $t->{hostError} eq "" ) { $t->{XferLOG}->write(\"This backup will fail because: $_\n"); @@ -304,6 +306,7 @@ sub readOutput || /^\s*restore directory \\/i || /^\s*Output is \/dev\/null/i || /^\s*Timezone is/i + || /^\s*tar_re_search set/i || /^\s*creating lame (up|low)case table/i ) { # ignore these messages