my $TopDir = $bpc->TopDir();
my $BinDir = $bpc->BinDir();
my %Conf = $bpc->Conf();
+my $NeedPostCmd;
$bpc->ChildInit();
# Make sure we eventually timeout if there is no activity from
# the data transport program.
#
-alarm($Conf{SmbClientTimeout});
+alarm($Conf{ClientTimeout});
mkpath($Dir, 0, 0777) if ( !-d $Dir );
if ( !-f "$Dir/LOCK" ) {
$ShareNames = [ $ShareNames ] unless ref($ShareNames) eq "ARRAY";
+#
+# Run an optional pre-dump command
+#
+UserCommandRun("DumpPreUserCmd");
+$NeedPostCmd = 1;
+
#
# Now backup each of the shares
#
# Use rsync as the transport program.
#
if ( !defined($xfer = BackupPC::Xfer::Rsync->new($bpc)) ) {
- print(LOG $bpc->timeStamp,
- "dump failed: File::RsyncP module is not installed\n");
- print("dump failed: Rsync module is not installed\n");
+ my $errStr = BackupPC::Xfer::Rsync::errStr;
+ print(LOG $bpc->timeStamp, "dump failed: $errStr\n");
+ print("dump failed: $errStr\n");
+ UserCommandRun("DumpPostUserCmd") if ( $NeedPostCmd );
exit(1);
}
} else {
#
$xfer = BackupPC::Xfer::Smb->new($bpc);
}
+
my $useTar = $xfer->useTar;
if ( $useTar ) {
lastFullBkupNum => $lastFullBkupNum,
backups => \@Backups,
compress => $Conf{CompressLevel},
- XferMethod => => $Conf{XferMethod},
+ XferMethod => $Conf{XferMethod},
});
if ( !defined($logMsg = $xfer->start()) ) {
sleep(1);
kill(9, $tarPid);
}
+ UserCommandRun("DumpPostUserCmd") if ( $NeedPostCmd );
exit(1);
}
last;
}
}
-$XferLOG->close();
-close($newFilesFH) if ( defined($newFilesFH) );
-
my $lastNum = -1;
#
$stat{hostError} = $errMsg;
$stat{xferOK} = 0;
}
+
+UserCommandRun("DumpPostUserCmd") if ( $NeedPostCmd );
+$XferLOG->close();
+close($newFilesFH) if ( defined($newFilesFH) );
+
if ( $stat{xferOK} ) {
@Backups = $bpc->BackupInfoRead($host);
for ( my $i = 0 ; $i < @Backups ; $i++ ) {
my $fileExt = $Conf{CompressLevel} > 0 ? ".z" : "";
print(LOG $bpc->timeStamp, "cleaning up after signal $signame\n");
+ UserCommandRun("DumpPostUserCmd") if ( $NeedPostCmd );
$XferLOG->write(\"exiting after signal $signame\n");
$XferLOG->close();
if ( $xferPid > 0 ) {
if ( $netBiosHost ne $host );
return;
}
+
+#
+# Run an optional pre- or post-dump command
+#
+sub UserCommandRun
+{
+ my($type) = @_;
+
+ return if ( !defined($Conf{$type}) );
+ my $vars = {
+ xfer => $xfer,
+ host => $host,
+ hostIP => $hostIP,
+ share => $ShareNames->[0],
+ shares => $ShareNames,
+ XferMethod => $Conf{XferMethod},
+ LOG => *LOG,
+ XferLOG => $XferLOG,
+ stat => \%stat,
+ xferOK => $stat{xferOK},
+ type => $type,
+ };
+ my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars);
+ $XferLOG->write(\"Executing $type: @$cmd\n");
+ #
+ # Run the user's command, dumping the stdout/stderr into the
+ # Xfer log file. Also supply the optional $vars and %Conf in
+ # case the command is really perl code instead of a shell
+ # command.
+ #
+ $bpc->cmdSystemOrEval($cmd,
+ sub {
+ $XferLOG->write(\$_[0]);
+ },
+ $vars, \%Conf);
+}