projects
/
BackupPC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* minor changes to makeDist and lib/BackupPC/Lang/zh_CN.pm
[BackupPC.git]
/
lib
/
BackupPC
/
Xfer
/
Tar.pm
diff --git
a/lib/BackupPC/Xfer/Tar.pm
b/lib/BackupPC/Xfer/Tar.pm
index
e9b2945
..
60bfd36
100644
(file)
--- a/
lib/BackupPC/Xfer/Tar.pm
+++ b/
lib/BackupPC/Xfer/Tar.pm
@@
-29,7
+29,7
@@
#
#========================================================================
#
#
#========================================================================
#
-# Version 3.0.0
alpha, released 23 Jan 2006
.
+# Version 3.0.0
, released 28 Jan 2007
.
#
# See http://backuppc.sourceforge.net.
#
#
# See http://backuppc.sourceforge.net.
#
@@
-38,6
+38,7
@@
package BackupPC::Xfer::Tar;
use strict;
package BackupPC::Xfer::Tar;
use strict;
+use Encode qw/from_to encode/;
sub new
{
sub new
{
@@
-100,13
+101,19
@@
sub start
if ( defined($conf->{BackupFilesExclude}{$t->{shareName}}) ) {
foreach my $file ( @{$conf->{BackupFilesExclude}{$t->{shareName}}} )
{
if ( defined($conf->{BackupFilesExclude}{$t->{shareName}}) ) {
foreach my $file ( @{$conf->{BackupFilesExclude}{$t->{shareName}}} )
{
- $file = ".$file" if ( $file =~ /^\// );
+ $file = $2 if ( $file =~ m{^(\./+|/+)(.*)}s );
+ $file = "./$file";
+ $file = encode($conf->{ClientCharset}, $file)
+ if ( $conf->{ClientCharset} ne "" );
push(@fileList, "--exclude=$file");
}
}
if ( defined($conf->{BackupFilesOnly}{$t->{shareName}}) ) {
foreach my $file ( @{$conf->{BackupFilesOnly}{$t->{shareName}}} ) {
push(@fileList, "--exclude=$file");
}
}
if ( defined($conf->{BackupFilesOnly}{$t->{shareName}}) ) {
foreach my $file ( @{$conf->{BackupFilesOnly}{$t->{shareName}}} ) {
- $file = ".$file" if ( $file =~ /^\// );
+ $file = $2 if ( $file =~ m{^(\./+|/+)(.*)}s );
+ $file = "./$file";
+ $file = encode($conf->{ClientCharset}, $file)
+ if ( $conf->{ClientCharset} ne "" );
push(@fileList, $file);
}
} else {
push(@fileList, $file);
}
} else {
@@
-143,6
+150,8
@@
sub start
tarPath => $conf->{TarClientPath},
sshPath => $conf->{SshPath},
};
tarPath => $conf->{TarClientPath},
sshPath => $conf->{SshPath},
};
+ from_to($args->{shareName}, "utf8", $conf->{ClientCharset})
+ if ( $conf->{ClientCharset} ne "" );
$tarClientCmd = $bpc->cmdVarSubstitute($tarClientCmd, $args);
if ( !defined($t->{xferPid} = open(TAR, "-|")) ) {
$t->{_errStr} = "Can't fork to run tar";
$tarClientCmd = $bpc->cmdVarSubstitute($tarClientCmd, $args);
if ( !defined($t->{xferPid} = open(TAR, "-|")) ) {
$t->{_errStr} = "Can't fork to run tar";
@@
-184,6
+193,8
@@
sub start
return;
}
my $str = "Running: " . $bpc->execCmd2ShellCmd(@$tarClientCmd) . "\n";
return;
}
my $str = "Running: " . $bpc->execCmd2ShellCmd(@$tarClientCmd) . "\n";
+ from_to($str, $conf->{ClientCharset}, "utf8")
+ if ( $conf->{ClientCharset} ne "" );
$t->{XferLOG}->write(\"Running: @$tarClientCmd\n");
alarm($conf->{ClientTimeout});
$t->{_errStr} = undef;
$t->{XferLOG}->write(\"Running: @$tarClientCmd\n");
alarm($conf->{ClientTimeout});
$t->{_errStr} = undef;
@@
-199,7
+210,12
@@
sub readOutput
my $mesg;
if ( sysread($t->{pipeTar}, $mesg, 8192) <= 0 ) {
vec($$FDreadRef, fileno($t->{pipeTar}), 1) = 0;
my $mesg;
if ( sysread($t->{pipeTar}, $mesg, 8192) <= 0 ) {
vec($$FDreadRef, fileno($t->{pipeTar}), 1) = 0;
- if ( !close($t->{pipeTar}) ) {
+ if ( !close($t->{pipeTar}) && $? != 256 ) {
+ #
+ # Tar 1.16 uses exit status 1 (256) when some files
+ # changed during archive creation. We allow this
+ # as a benign error and consider the archive ok
+ #
$t->{tarOut} .= "Tar exited with error $? ($!) status\n";
$t->{xferOK} = 0 if ( !$t->{tarBadExitOk} );
}
$t->{tarOut} .= "Tar exited with error $? ($!) status\n";
$t->{xferOK} = 0 if ( !$t->{tarBadExitOk} );
}
@@
-207,25
+223,28
@@
sub readOutput
$t->{tarOut} .= $mesg;
}
}
$t->{tarOut} .= $mesg;
}
}
+ my $logFileThres = $t->{type} eq "restore" ? 1 : 2;
while ( $t->{tarOut} =~ /(.*?)[\n\r]+(.*)/s ) {
$_ = $1;
$t->{tarOut} = $2;
while ( $t->{tarOut} =~ /(.*?)[\n\r]+(.*)/s ) {
$_ = $1;
$t->{tarOut} = $2;
+ from_to($_, $conf->{ClientCharset}, "utf8")
+ if ( $conf->{ClientCharset} ne "" );
#
# refresh our inactivity alarm
#
alarm($conf->{ClientTimeout}) if ( !$t->{abort} );
$t->{lastOutputLine} = $_ if ( !/^$/ );
#
# refresh our inactivity alarm
#
alarm($conf->{ClientTimeout}) if ( !$t->{abort} );
$t->{lastOutputLine} = $_ if ( !/^$/ );
- if ( /^Total bytes
written
: / ) {
+ if ( /^Total bytes
(written|read)
: / ) {
$t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 );
$t->{xferOK} = 1;
} elsif ( /^\./ ) {
$t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 );
$t->{xferOK} = 1;
} elsif ( /^\./ ) {
- $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >=
2
);
+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >=
$logFileThres
);
$t->{fileCnt}++;
} else {
#
# Ignore annoying log message on incremental for tar 1.15.x
#
$t->{fileCnt}++;
} else {
#
# Ignore annoying log message on incremental for tar 1.15.x
#
- if ( !/: file is unchanged; not dumped$/ ) {
+ if ( !/: file is unchanged; not dumped$/
&& !/: socket ignored$/
) {
$t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 );
$t->{xferErrCnt}++;
}
$t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 );
$t->{xferErrCnt}++;
}