# Craig Barratt <cbarratt@users.sourceforge.net>
#
# 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
my $lastIncrTime = 0;
my $partialIdx = -1;
my $partialNum;
+my $partialFileCnt;
my $lastBkupNum;
my $lastPartial = 0;
$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};
}
}
#
# 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 ) {
# 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);
}
#