# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
-# Copyright (C) 2001-2003 Craig Barratt
+# Copyright (C) 2001-2007 Craig Barratt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#
#========================================================================
#
-# Version 2.1.0beta1, released 9 Apr 2004.
+# Version 3.1.0, released 25 Nov 2007.
#
# See http://backuppc.sourceforge.net.
#
package BackupPC::Xfer::Smb;
use strict;
+use Encode qw/from_to encode/;
sub new
{
} 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);
}
#
} 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 = {
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, "-|")) ) {
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;
#
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.
|| /^\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");