X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FXfer%2FTar.pm;h=8c05492727411ac195e3f9ef8422e409318c68c9;hp=53589435015a86e48d80b1845f7935e1ae7390bb;hb=2460880d23902e74d5d8541f9c2fbb9538eaf4cb;hpb=3ec73efe5ee035c9cda24dc70500157e455d9c84 diff --git a/lib/BackupPC/Xfer/Tar.pm b/lib/BackupPC/Xfer/Tar.pm index 5358943..8c05492 100644 --- a/lib/BackupPC/Xfer/Tar.pm +++ b/lib/BackupPC/Xfer/Tar.pm @@ -11,7 +11,7 @@ # Craig Barratt # # 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 @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.0.0beta2, released 13 Apr 2003. +# Version 2.1.0_CVS, released 8 Feb 2004. # # See http://backuppc.sourceforge.net. # @@ -135,7 +135,7 @@ sub start $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}"; @@ -189,6 +189,7 @@ sub start # # Run the tar command # + alarm(0); $bpc->cmdExecOrEval($tarClientCmd, $args); # should not be reached, but just in case... $t->{_errStr} = "Can't exec @$tarClientCmd"; @@ -221,17 +222,19 @@ sub readOutput 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 @@ -240,11 +243,34 @@ sub readOutput # $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) = @_;