# 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
#
#========================================================================
#
-# Version 2.0.0_CVS, released 18 Jan 2003.
+# Version 2.1.0, released 20 Jun 2004.
#
# See http://backuppc.sourceforge.net.
#
} else {
#
# Turn $conf->{BackupFilesOnly} and $conf->{BackupFilesExclude}
- # into a hash of arrays of files
+ # into a hash of arrays of files, and $conf->{TarShareName}
+ # to an array
#
- $conf->{TarShareName} = [ $conf->{TarShareName} ]
- unless ref($conf->{TarShareName}) eq "ARRAY";
- foreach my $param qw(BackupFilesOnly BackupFilesExclude) {
- next if ( !defined($conf->{$param}) );
- if ( ref($conf->{$param}) eq "ARRAY" ) {
- $conf->{$param} = {
- $conf->{TarShareName}[0] => $conf->{$param}
- };
- } elsif ( ref($conf->{$param}) eq "HASH" ) {
- # do nothing
- } else {
- $conf->{$param} = {
- $conf->{TarShareName}[0] => [ $conf->{$param} ]
- };
- }
- }
+ $bpc->backupFileConfFix($conf, "TarShareName");
+
if ( defined($conf->{BackupFilesExclude}{$t->{shareName}}) ) {
foreach my $file ( @{$conf->{BackupFilesExclude}{$t->{shareName}}} )
{
$args = $conf->{TarFullArgs};
$logMsg = "full backup started for directory $t->{shareName}";
} else {
- $incrDate = $bpc->timeStampISO($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}";
#
# Run the tar command
#
+ alarm(0);
$bpc->cmdExecOrEval($tarClientCmd, $args);
# should not be reached, but just in case...
$t->{_errStr} = "Can't exec @$tarClientCmd";
while ( $t->{tarOut} =~ /(.*?)[\n\r]+(.*)/s ) {
$_ = $1;
$t->{tarOut} = $2;
- $t->{XferLOG}->write(\"$_\n");
#
# refresh our inactivity alarm
#
- alarm($conf->{ClientTimeout});
+ alarm($conf->{ClientTimeout}) if ( !$t->{abort} );
$t->{lastOutputLine} = $_ if ( !/^$/ );
if ( /^Total bytes written: / ) {
+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 );
$t->{xferOK} = 1;
} elsif ( /^\./ ) {
+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 2 );
$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->{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;
}
+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) = @_;
{
my($t) = @_;
- return $t->{xferPid};
+ return ($t->{xferPid});
}
sub logMsg