X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_dump;h=b54c208c5c5bc02d3f71c6dc73022dba5d27f837;hp=8da28c34d9f1f5fbb6b617750284e009457454d4;hb=f8c20efc11f400acafb7833947bae6c299467ef6;hpb=fadae1eaa5482a441bc8e8aa829a063ee6a5f0c0 diff --git a/bin/BackupPC_dump b/bin/BackupPC_dump index 8da28c3..b54c208 100755 --- a/bin/BackupPC_dump +++ b/bin/BackupPC_dump @@ -52,7 +52,7 @@ # Craig Barratt # # 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 @@ -70,7 +70,7 @@ # #======================================================================== # -# Version 3.1.0beta0, released 3 Sep 2007. +# Version 3.1.0, released 25 Nov 2007. # # See http://backuppc.sourceforge.net. # @@ -303,6 +303,7 @@ my $lastFullTime = 0; my $lastIncrTime = 0; my $partialIdx = -1; my $partialNum; +my $partialFileCnt; my $lastBkupNum; my $lastPartial = 0; @@ -405,9 +406,10 @@ for ( my $i = 0 ; $i < @Backups ; $i++ ) { $lastIncrTime = $Backups[$i]{startTime} if ( $lastIncrTime < $Backups[$i]{startTime} ); } elsif ( $Backups[$i]{type} eq "partial" ) { - $partialIdx = $i; - $lastPartial = $Backups[$i]{startTime}; - $partialNum = $Backups[$i]{num}; + $partialIdx = $i; + $lastPartial = $Backups[$i]{startTime}; + $partialNum = $Backups[$i]{num}; + $partialFileCnt = $Backups[$i]{nFiles}; } } @@ -985,6 +987,11 @@ my $newNum = BackupSave(); my $otherCount = $stat{xferErrCnt} - $stat{xferBadFileCnt} - $stat{xferBadShareCnt}; +$stat{fileCnt} ||= 0; +$stat{byteCnt} ||= 0; +$stat{xferErrCnt} ||= 0; +$stat{xferBadFileCnt} ||= 0; +$stat{xferBadShareCnt} ||= 0; print(LOG $bpc->timeStamp, "$type backup $newNum complete, $stat{fileCnt} files," . " $stat{byteCnt} bytes," @@ -1128,7 +1135,9 @@ sub BackupFailCleanup # # We keep this backup if it is a full and we actually backed - # up some files. + # up some files. If the prior backup was a partial too, we + # only keep this backup if it has more files than the previous + # partial. # if ( $type eq "full" ) { if ( $nFilesTotal == 0 && $xfer->getStats->{fileCnt} == 0 ) { @@ -1137,13 +1146,29 @@ sub BackupFailCleanup # directory just in case. # find(\&CheckForNewFiles, "$Dir/new"); - $keepPartial = 1 if ( $nFilesTotal ); - } else { - # - # Xfer reported some files - # + } + my $str; + if ( $nFilesTotal > $partialFileCnt + || $xfer->getStats->{fileCnt} > $partialFileCnt ) { + # + # If the last backup wasn't a partial then + # $partialFileCnt is undefined, so the above + # test is simply $nFilesTotal > 0 + # $keepPartial = 1; - } + if ( $partialFileCnt ) { + $str = "Saving this as a partial backup\n"; + } else { + $str = sprintf("Saving this as a partial backup, replacing the" + . " prior one (got %d and %d files versus %d)\n", + $nFilesTotal, $xfer->getStats->{fileCnt}, $partialFileCnt); + } + } else { + $str = sprintf("Not saving this as a partial backup since it has fewer" + . " files than the prior one (got %d and %d files versus %d)\n", + $nFilesTotal, $xfer->getStats->{fileCnt}, $partialFileCnt); + } + $XferLOG->write(\$str); } #