* Commit for 2.1.0.
[BackupPC.git] / bin / BackupPC_dump
index 2f3b7a3..62173e7 100755 (executable)
@@ -70,7 +70,7 @@
 #
 #========================================================================
 #
 #
 #========================================================================
 #
-# Version 2.1.0beta0, released 20 Mar 2004.
+# Version 2.1.0, released 20 Jun 2004.
 #
 # See http://backuppc.sourceforge.net.
 #
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -276,6 +276,7 @@ my $lastFull = 0;
 my $lastIncr = 0;
 my $partialIdx = -1;
 my $partialNum;
 my $lastIncr = 0;
 my $partialIdx = -1;
 my $partialNum;
+my $lastPartial = 0;
 
 if ( $Conf{FullPeriod} == -1 && !$opts{f} && !$opts{i}
         || $Conf{FullPeriod} == -2 ) {
 
 if ( $Conf{FullPeriod} == -1 && !$opts{f} && !$opts{i}
         || $Conf{FullPeriod} == -2 ) {
@@ -375,8 +376,9 @@ for ( my $i = 0 ; $i < @Backups ; $i++ ) {
         $lastIncr = $Backups[$i]{startTime}
                 if ( $lastIncr < $Backups[$i]{startTime} );
     } elsif ( $Backups[$i]{type} eq "partial" ) {
         $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};
     }
 }
 
     }
 }
 
@@ -444,10 +446,10 @@ if ( !defined($XferLOG) ) {
 }
 
 #
 }
 
 #
-# 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;
 }
     $partialNum = undef;
     $partialIdx = -1;
 }
@@ -1008,6 +1010,11 @@ sub BackupFailCleanup
        }
     }
 
        }
     }
 
+    #
+    # 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.
     if ( !$keepPartial ) {
         #
         # No point in saving this dump; get rid of eveything.
@@ -1095,8 +1102,25 @@ sub BackupExpire
         # Delete any old full backups, according to $Conf{FullKeepCntMin}
        # and $Conf{FullAgeMax}.
         #
         # 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}
         if ( $cntFull > $Conf{FullKeepCntMin}
                && $oldestFull > $Conf{FullAgeMax}
+               && $oldestFull > $fullAgeMax
+              && $Conf{FullKeepCntMin} > 0
+              && $Conf{FullAgeMax} > 0
                && (@Backups <= $firstFull + 1
                         || !$Backups[$firstFull + 1]{noFill}) ) {
             #
                && (@Backups <= $firstFull + 1
                         || !$Backups[$firstFull + 1]{noFill}) ) {
             #
@@ -1360,9 +1384,9 @@ sub pidHandler
 #
 sub UserCommandRun
 {
 #
 sub UserCommandRun
 {
-    my($type) = @_;
+    my($cmdType) = @_;
 
 
-    return if ( !defined($Conf{$type}) );
+    return if ( !defined($Conf{$cmdType}) );
     my $vars = {
         xfer       => $xfer,
         client     => $client,
     my $vars = {
         xfer       => $xfer,
         client     => $client,
@@ -1380,9 +1404,10 @@ sub UserCommandRun
         xferOK     => $stat{xferOK} || 0,
        hostError  => $stat{hostError},
        type       => $type,
         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
     #
     # Run the user's command, dumping the stdout/stderr into the
     # Xfer log file.  Also supply the optional $vars and %Conf in