#
#========================================================================
#
-# Version 2.1.0_CVS, released 8 Feb 2004.
+# Version 3.0.0beta0, released 11 Jul 2006.
#
# See http://backuppc.sourceforge.net.
#
use BackupPC::Xfer::Smb;
use BackupPC::Xfer::Tar;
use BackupPC::Xfer::Rsync;
+use BackupPC::Xfer::BackupPCd;
use Socket;
use File::Path;
#
# Setup file extension for compression and open RestoreLOG output file
#
-$Conf{CompressLevel} = 0 if ( !BackupPC::FileZIO->compOk );
+if ( $Conf{CompressLevel} && !BackupPC::FileZIO->compOk ) {
+ $stat{hostError} = "Compress:Zlib not found";
+ exit(RestoreCleanup($client));
+}
my $fileExt = $Conf{CompressLevel} > 0 ? ".z" : "";
my $RestoreLOG = BackupPC::FileZIO->open("$Dir/RestoreLOG$fileExt", 1,
$Conf{CompressLevel});
# Run an optional pre-restore command
#
UserCommandRun("RestorePreUserCmd");
+if ( $? && $Conf{UserCmdCheckStatus} ) {
+ $stat{hostError} = "RestorePreUserCmd returned error status $?";
+ exit(RestoreCleanup($client));
+}
$NeedPostCmd = 1;
if ( $Conf{XferMethod} eq "tar" ) {
$stat{hostError} = $errStr;
exit(RestoreCleanup($client));
}
+} elsif ( $Conf{XferMethod} eq "backuppcd" ) {
+ #
+ # Use backuppcd as the transport program.
+ #
+ if ( !defined($xfer = BackupPC::Xfer::BackupPCd->new($bpc)) ) {
+ my $errStr = BackupPC::Xfer::BackupPCd->errStr;
+ UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
+ $stat{hostError} = $errStr;
+ exit(RestoreCleanup($client));
+ }
} else {
#
# Default is to use smbclient (smb) as the transport program.
#
# Run an optional post-restore command
#
- UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
+ if ( $NeedPostCmd ) {
+ UserCommandRun("RestorePostUserCmd");
+ if ( $? && $Conf{UserCmdCheckStatus} ) {
+ $stat{hostError} = "RestorePostUserCmd returned error status $?";
+ $stat{xferOK} = 0;
+ }
+ }
rename("$Dir/RestoreLOG$fileExt", "$Dir/RestoreLOG.$lastNum$fileExt");
rename("$Dir/$reqFileName", "$Dir/RestoreInfo.$lastNum");
#
sub UserCommandRun
{
- my($type) = @_;
+ my($cmdType) = @_;
- return if ( !defined($Conf{$type}) );
+ return if ( !defined($Conf{$cmdType}) );
my $vars = {
xfer => $xfer,
client => $client,
stat => \%stat,
xferOK => $stat{xferOK} || 0,
hostError => $stat{hostError},
- type => $type,
+ type => "restore",
bkupSrcHost => $RestoreReq{hostSrc},
bkupSrcShare => $RestoreReq{shareSrc},
bkupSrcNum => $RestoreReq{num},
pathHdrSrc => $RestoreReq{pathHdrSrc},
pathHdrDest => $RestoreReq{pathHdrDest},
fileList => $RestoreReq{fileList},
+ cmdType => $cmdType,
};
- my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars);
- $RestoreLOG->write(\"Executing $type: @$cmd\n");
+ my $cmd = $bpc->cmdVarSubstitute($Conf{$cmdType}, $vars);
+ $RestoreLOG->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