#
#========================================================================
#
-# Version 2.1.0beta1, released 9 Apr 2004.
+# Version 2.1.0, released 20 Jun 2004.
#
# See http://backuppc.sourceforge.net.
#
my $lastIncr = 0;
my $partialIdx = -1;
my $partialNum;
+my $lastPartial = 0;
if ( $Conf{FullPeriod} == -1 && !$opts{f} && !$opts{i}
|| $Conf{FullPeriod} == -2 ) {
}
if ( !$opts{i} && !$opts{f} && $StatusHost{backoffTime} > time ) {
- printf(LOG "%sskipping because of user requested delay (%.1f hours left)",
+ printf(LOG "%sskipping because of user requested delay (%.1f hours left)\n",
$bpc->timeStamp, ($StatusHost{backoffTime} - time) / 3600);
NothingToDo($needLink);
}
$lastIncr = $Backups[$i]{startTime}
if ( $lastIncr < $Backups[$i]{startTime} );
} elsif ( $Backups[$i]{type} eq "partial" ) {
- $partialIdx = $i;
- $partialNum = $Backups[$i]{num};
+ $partialIdx = $i;
+ $lastPartial = $Backups[$i]{startTime};
+ $partialNum = $Backups[$i]{num};
}
}
}
#
-# Ignore the partial dump in the case of an incremental.
-# A partial is a partial full.
+# Ignore the partial dump in the case of an incremental
+# or when the partial is too old. A partial is a partial full.
#
-if ( $type ne "full" ) {
+if ( $type ne "full" || time - $lastPartial > $Conf{PartialAgeMax} * 24*3600 ) {
$partialNum = undef;
$partialIdx = -1;
}
}
}
+ #
+ # Don't keep partials if they are disabled
+ #
+ $keepPartial = 0 if ( $Conf{PartialAgeMax} < 0 );
+
if ( !$keepPartial ) {
#
# No point in saving this dump; get rid of eveything.
# Delete any old full backups, according to $Conf{FullKeepCntMin}
# and $Conf{FullAgeMax}.
#
+ # First make sure that $Conf{FullAgeMax} is at least bigger
+ # than $Conf{FullPeriod} * $Conf{FullKeepCnt}, including
+ # the exponential array case.
+ #
+ my $fullKeepCnt = $Conf{FullKeepCnt};
+ $fullKeepCnt = [$fullKeepCnt] if ( ref($fullKeepCnt) ne "ARRAY" );
+ my $fullAgeMax;
+ my $fullPeriod = int(0.5 + $Conf{FullPeriod});
+ for ( my $i = 0 ; $i < @$fullKeepCnt ; $i++ ) {
+ $fullAgeMax += $fullKeepCnt->[$i] * $fullPeriod;
+ $fullPeriod *= 2;
+ }
+ $fullAgeMax += $fullPeriod; # add some buffer
+
if ( $cntFull > $Conf{FullKeepCntMin}
&& $oldestFull > $Conf{FullAgeMax}
+ && $oldestFull > $fullAgeMax
+ && $Conf{FullKeepCntMin} > 0
+ && $Conf{FullAgeMax} > 0
&& (@Backups <= $firstFull + 1
|| !$Backups[$firstFull + 1]{noFill}) ) {
#
#
sub UserCommandRun
{
- my($type) = @_;
+ my($cmdType) = @_;
- return if ( !defined($Conf{$type}) );
+ return if ( !defined($Conf{$cmdType}) );
my $vars = {
xfer => $xfer,
client => $client,
xferOK => $stat{xferOK} || 0,
hostError => $stat{hostError},
type => $type,
+ cmdType => $cmdType,
};
- my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars);
- $XferLOG->write(\"Executing $type: @$cmd\n");
+ my $cmd = $bpc->cmdVarSubstitute($Conf{$cmdType}, $vars);
+ $XferLOG->write(\"Executing $cmdType: @$cmd\n");
#
# Run the user's command, dumping the stdout/stderr into the
# Xfer log file. Also supply the optional $vars and %Conf in