projects
/
BackupPC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- updated version to BackupPC-2.1.0beta0
[BackupPC.git]
/
lib
/
BackupPC
/
Xfer
/
Tar.pm
diff --git
a/lib/BackupPC/Xfer/Tar.pm
b/lib/BackupPC/Xfer/Tar.pm
index
60326e1
..
1de40ff
100644
(file)
--- a/
lib/BackupPC/Xfer/Tar.pm
+++ b/
lib/BackupPC/Xfer/Tar.pm
@@
-11,7
+11,7
@@
# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
-# Copyright (C) 2001 Craig Barratt
+# Copyright (C) 2001
-2003
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
#
# 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
@@
-29,7
+29,7
@@
#
#========================================================================
#
#
#========================================================================
#
-# Version
1.6.0_CVS, released 10 Dec 2002
.
+# Version
2.1.0beta0, released 20 Mar 2004
.
#
# See http://backuppc.sourceforge.net.
#
#
# See http://backuppc.sourceforge.net.
#
@@
-82,11
+82,7
@@
sub start
local(*TAR);
if ( $t->{type} eq "restore" ) {
local(*TAR);
if ( $t->{type} eq "restore" ) {
- if ( ref($conf->{TarClientRestoreCmd}) eq "ARRAY" ) {
- $tarClientCmd = $conf->{TarClientRestoreCmd};
- } else {
- $tarClientCmd = [split(/ +/, $conf->{TarClientRestoreCmd})];
- }
+ $tarClientCmd = $conf->{TarClientRestoreCmd};
$logMsg = "restore started below directory $t->{shareName}";
#
# restores are considered to work unless we see they fail
$logMsg = "restore started below directory $t->{shareName}";
#
# restores are considered to work unless we see they fail
@@
-139,7
+135,7
@@
sub start
$args = $conf->{TarFullArgs};
$logMsg = "full backup started for directory $t->{shareName}";
} else {
$args = $conf->{TarFullArgs};
$logMsg = "full backup started for directory $t->{shareName}";
} else {
- $incrDate = $bpc->timeStamp
ISO
($t->{lastFull} - 3600, 1);
+ $incrDate = $bpc->timeStamp($t->{lastFull} - 3600, 1);
$args = $conf->{TarIncrArgs};
$logMsg = "incr backup started back to $incrDate for directory"
. " $t->{shareName}";
$args = $conf->{TarIncrArgs};
$logMsg = "incr backup started back to $incrDate for directory"
. " $t->{shareName}";
@@
-149,15
+145,17
@@
sub start
#
# Merge variables into @tarClientCmd
#
#
# Merge variables into @tarClientCmd
#
-
$tarClientCmd = $bpc->cmdVarSubstitute($tarClientCmd,
{
+
my $args =
{
host => $t->{host},
hostIP => $t->{hostIP},
host => $t->{host},
hostIP => $t->{hostIP},
+ client => $t->{client},
incrDate => $incrDate,
shareName => $t->{shareName},
fileList => \@fileList,
tarPath => $conf->{TarClientPath},
sshPath => $conf->{SshPath},
incrDate => $incrDate,
shareName => $t->{shareName},
fileList => \@fileList,
tarPath => $conf->{TarClientPath},
sshPath => $conf->{SshPath},
- });
+ };
+ $tarClientCmd = $bpc->cmdVarSubstitute($tarClientCmd, $args);
if ( !defined($t->{xferPid} = open(TAR, "-|")) ) {
$t->{_errStr} = "Can't fork to run tar";
return;
if ( !defined($t->{xferPid} = open(TAR, "-|")) ) {
$t->{_errStr} = "Can't fork to run tar";
return;
@@
-191,11
+189,13
@@
sub start
#
# Run the tar command
#
#
# Run the tar command
#
- $bpc->cmdExecOrEval($tarClientCmd);
+ alarm(0);
+ $bpc->cmdExecOrEval($tarClientCmd, $args);
# should not be reached, but just in case...
$t->{_errStr} = "Can't exec @$tarClientCmd";
return;
}
# should not be reached, but just in case...
$t->{_errStr} = "Can't exec @$tarClientCmd";
return;
}
+ my $str = "Running: " . $bpc->execCmd2ShellCmd(@$tarClientCmd) . "\n";
$t->{XferLOG}->write(\"Running: @$tarClientCmd\n");
alarm($conf->{ClientTimeout});
$t->{_errStr} = undef;
$t->{XferLOG}->write(\"Running: @$tarClientCmd\n");
alarm($conf->{ClientTimeout});
$t->{_errStr} = undef;
@@
-222,17
+222,19
@@
sub readOutput
while ( $t->{tarOut} =~ /(.*?)[\n\r]+(.*)/s ) {
$_ = $1;
$t->{tarOut} = $2;
while ( $t->{tarOut} =~ /(.*?)[\n\r]+(.*)/s ) {
$_ = $1;
$t->{tarOut} = $2;
- $t->{XferLOG}->write(\"$_\n");
#
# refresh our inactivity alarm
#
#
# refresh our inactivity alarm
#
- alarm($conf->{ClientTimeout});
+ alarm($conf->{ClientTimeout})
if ( !$t->{abort} )
;
$t->{lastOutputLine} = $_ if ( !/^$/ );
if ( /^Total bytes written: / ) {
$t->{lastOutputLine} = $_ if ( !/^$/ );
if ( /^Total bytes written: / ) {
+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 );
$t->{xferOK} = 1;
} elsif ( /^\./ ) {
$t->{xferOK} = 1;
} elsif ( /^\./ ) {
+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 2 );
$t->{fileCnt}++;
} else {
$t->{fileCnt}++;
} else {
+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 );
$t->{xferErrCnt}++;
#
# If tar encounters a minor error, it will exit with a non-zero
$t->{xferErrCnt}++;
#
# If tar encounters a minor error, it will exit with a non-zero
@@
-241,11
+243,34
@@
sub readOutput
#
$t->{tarBadExitOk} = 1
if ( $t->{xferOK} && /Error exit delayed from previous / );
#
$t->{tarBadExitOk} = 1
if ( $t->{xferOK} && /Error exit delayed from previous / );
+ #
+ # Also remember files that had read errors
+ #
+ if ( /: \.\/(.*): Read error at byte / ) {
+ my $badFile = $1;
+ push(@{$t->{badFiles}}, {
+ share => $t->{shareName},
+ file => $badFile
+ });
+ }
+
}
}
return 1;
}
}
}
return 1;
}
+sub abort
+{
+ my($t, $reason) = @_;
+ my @xferPid = $t->xferPid;
+
+ $t->{abort} = 1;
+ $t->{abortReason} = $reason;
+ if ( @xferPid ) {
+ kill($t->{bpc}->sigName2num("INT"), @xferPid);
+ }
+}
+
sub setSelectMask
{
my($t, $FDreadRef) = @_;
sub setSelectMask
{
my($t, $FDreadRef) = @_;
@@
-264,7
+289,7
@@
sub xferPid
{
my($t) = @_;
{
my($t) = @_;
- return
$t->{xferPid}
;
+ return
($t->{xferPid})
;
}
sub logMsg
}
sub logMsg