* Language file updates
[BackupPC.git] / bin / BackupPC_dump
index 2b1d300..b974172 100755 (executable)
@@ -70,7 +70,7 @@
 #
 #========================================================================
 #
-# Version 2.1.0beta0, released 20 Mar 2004.
+# Version 2.1.0beta2, released 23 May 2004.
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -276,18 +276,20 @@ my $lastFull = 0;
 my $lastIncr = 0;
 my $partialIdx = -1;
 my $partialNum;
+my $lastPartial = 0;
 
 if ( $Conf{FullPeriod} == -1 && !$opts{f} && !$opts{i}
         || $Conf{FullPeriod} == -2 ) {
     print(STDERR "Exiting because backups are disabled with"
-               . "\$Conf{FullPeriod} = $Conf{FullPeriod}\n") if ( $opts{v} );
+               . " \$Conf{FullPeriod} = $Conf{FullPeriod}\n") if ( $opts{v} );
     #
     # Tell BackupPC to ignore old failed backups on hosts that
     # have backups disabled.
     #
     print("backups disabled\n")
-               if ( $StatusHost{reason} ne "Reason_backup_done"
-                    && time - $StatusHost{startTime} > 2 * 24 * 3600 );
+               if ( defined($StatusHost{errorTime})
+                    && $StatusHost{reason} ne "Reason_backup_done"
+                    && time - $StatusHost{errorTime} > 4 * 24 * 3600 );
     NothingToDo($needLink);
 }
 
@@ -374,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" ) {
-        $partialIdx = $i;
-        $partialNum = $Backups[$i]{num};
+        $partialIdx  = $i;
+        $lastPartial = $Backups[$i]{startTime};
+        $partialNum  = $Backups[$i]{num};
     }
 }
 
@@ -443,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;
 }
@@ -1007,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.
@@ -1094,8 +1102,25 @@ sub BackupExpire
         # 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 $oldestFull;
+       my $fullPeriod = int(0.5 + $Conf{FullPeriod});
+       for ( my $i = 0 ; $i < @$fullKeepCnt ; $i++ ) {
+           $oldestFull += $fullKeepCnt->[$i] * $fullPeriod;
+           $fullPeriod *= 2;
+       }
+       $oldestFull += $fullPeriod;     # add some buffer
+
         if ( $cntFull > $Conf{FullKeepCntMin}
                && $oldestFull > $Conf{FullAgeMax}
+               && $oldestFull > $oldestFull
+              && $Conf{FullKeepCntMin} > 0
+              && $Conf{FullAgeMax} > 0
                && (@Backups <= $firstFull + 1
                         || !$Backups[$firstFull + 1]{noFill}) ) {
             #