- fixed configure.pl and makeDist.
[BackupPC.git] / bin / BackupPC_restore
index 483615e..8f78316 100755 (executable)
@@ -29,7 +29,7 @@
 #
 #========================================================================
 #
-# Version 2.1.0beta1, released 9 Apr 2004.
+# Version 3.0.0alpha, released 23 Jan 2006.
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -43,6 +43,7 @@ use BackupPC::FileZIO;
 use BackupPC::Xfer::Smb;
 use BackupPC::Xfer::Tar;
 use BackupPC::Xfer::Rsync;
+use BackupPC::Xfer::BackupPCd;
 use Socket;
 
 use File::Path;
@@ -186,7 +187,10 @@ if ( (my $errMsg = CorrectHostCheck($hostIP, $host)) ) {
 #
 # 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});
@@ -221,6 +225,16 @@ 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.
@@ -611,9 +625,9 @@ sub pidHandler
 #
 sub UserCommandRun
 {
-    my($type) = @_;
+    my($cmdType) = @_;
 
-    return if ( !defined($Conf{$type}) );
+    return if ( !defined($Conf{$cmdType}) );
     my $vars = {
         xfer         => $xfer,
         client       => $client,
@@ -629,7 +643,7 @@ sub UserCommandRun
         stat         => \%stat,
         xferOK       => $stat{xferOK} || 0,
        hostError    => $stat{hostError},
-       type         => $type,
+       type         => "restore",
        bkupSrcHost  => $RestoreReq{hostSrc},
        bkupSrcShare => $RestoreReq{shareSrc},
        bkupSrcNum   => $RestoreReq{num},
@@ -637,9 +651,10 @@ sub UserCommandRun
        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