#
#========================================================================
#
-# Version 2.1.0beta2, released 23 May 2004.
+# Version 2.1.0, released 20 Jun 2004.
#
# See http://backuppc.sourceforge.net.
#
}
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);
}
#
# Setup file extension for compression and open XferLOG output file
#
-$Conf{CompressLevel} = 0 if ( !BackupPC::FileZIO->compOk );
+if ( $Conf{CompressLevel} && !BackupPC::FileZIO->compOk ) {
+ print(LOG $bpc->timeStamp, "dump failed: can't find Compress::Zlib\n");
+ print("dump failed: can't find Compress::Zlib\n");
+ exit(1);
+}
my $fileExt = $Conf{CompressLevel} > 0 ? ".z" : "";
my $XferLOG = BackupPC::FileZIO->open("$Dir/XferLOG$fileExt", 1,
$Conf{CompressLevel});
next;
}
+ UserCommandRun("DumpPreShareCmd", $shareName);
+
if ( $Conf{XferMethod} eq "tar" ) {
#
# Use tar (eg: tar/ssh) as the transport program.
my $errStr = BackupPC::Xfer::Rsync::errStr;
print(LOG $bpc->timeStamp, "dump failed: $errStr\n");
print("dump failed: $errStr\n");
+ UserCommandRun("DumpPostShareCmd", $shareName) if ( $NeedPostCmd );
UserCommandRun("DumpPostUserCmd") if ( $NeedPostCmd );
exit(1);
}
sleep(1);
kill($bpc->sigName2num("KILL"), @xferPid);
}
+ UserCommandRun("DumpPostShareCmd", $shareName) if ( $NeedPostCmd );
UserCommandRun("DumpPostUserCmd") if ( $NeedPostCmd );
exit(1);
}
next;
}
}
+
+ UserCommandRun("DumpPostShareCmd", $shareName) if ( $NeedPostCmd );
+
$stat{xferOK} = 0 if ( $stat{hostError} || $stat{hostAbort} );
if ( !$stat{xferOK} ) {
#
# 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});
+ $fullPeriod = 7 if ( $fullPeriod <= 0 );
+ 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}) ) {
#
#
# Delete the full backup
#
- #printf("Deleting backup $i ($prevFull)\n");
- push(@delete, $i);
+ #print("Deleting backup $i ($prevFull)\n");
+ unshift(@delete, $i);
} else {
$fullCnt++;
while ( $fullKeepIdx < @$fullKeepCnt
my($client, $Backups, $idx) = @_;
my($Dir) = "$TopDir/pc/$client";
+ if ( $Backups->[$idx]{num} eq "" ) {
+ print("BackupRemove: ignoring empty backup number for idx $idx\n");
+ return;
+ }
+
$bpc->RmTreeDefer("$TopDir/trash",
"$Dir/$Backups->[$idx]{num}");
unlink("$Dir/SmbLOG.$Backups->[$idx]{num}")
#
sub UserCommandRun
{
- my($type) = @_;
+ my($cmdType, $sharename) = @_;
- 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");
+
+ if ($cmdType eq 'DumpPreShareCmd' || $cmdType eq 'DumpPostShareCmd') {
+ $vars->{share} = $sharename;
+ }
+
+ 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