* Copyright date update
[BackupPC.git] / bin / BackupPC_restore
index 81eefaa..856a0a5 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/perl
+#!/usr/bin/perl
 #============================================================= -*-perl-*-
 #
 # BackupPC_restore: Restore files to a client.
 #============================================================= -*-perl-*-
 #
 # BackupPC_restore: Restore files to a client.
@@ -11,7 +11,7 @@
 #   Craig Barratt  <cbarratt@users.sourceforge.net>
 #
 # COPYRIGHT
 #   Craig Barratt  <cbarratt@users.sourceforge.net>
 #
 # COPYRIGHT
-#   Copyright (C) 2001-2003  Craig Barratt
+#   Copyright (C) 2001-2009  Craig Barratt
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 #
 #========================================================================
 #
 #
 #========================================================================
 #
-# Version 3.0.0, released 28 Jan 2007.
+# Version 3.2.0beta0, released 5 April 2009.
 #
 # See http://backuppc.sourceforge.net.
 #
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -40,10 +40,7 @@ no  utf8;
 use lib "/usr/local/BackupPC/lib";
 use BackupPC::Lib;
 use BackupPC::FileZIO;
 use lib "/usr/local/BackupPC/lib";
 use BackupPC::Lib;
 use BackupPC::FileZIO;
-use BackupPC::Xfer::Smb;
-use BackupPC::Xfer::Tar;
-use BackupPC::Xfer::Rsync;
-use BackupPC::Xfer::BackupPCd;
+use BackupPC::Xfer;
 use Socket;
 
 use File::Path;
 use Socket;
 
 use File::Path;
@@ -236,37 +233,14 @@ if ( $? && $Conf{UserCmdCheckStatus} ) {
 }
 $NeedPostCmd = 1;
 
 }
 $NeedPostCmd = 1;
 
-if ( $Conf{XferMethod} eq "tar" ) {
-    #
-    # Use tar (eg: tar/ssh) as the transport program.
-    #
-    $xfer = BackupPC::Xfer::Tar->new($bpc);
-} elsif ( $Conf{XferMethod} eq "rsync" || $Conf{XferMethod} eq "rsyncd" ) {
-    #
-    # Use rsync as the transport program.
-    #
-    if ( !defined($xfer = BackupPC::Xfer::Rsync->new($bpc)) ) {
-        my $errStr = BackupPC::Xfer::Rsync->errStr;
-       UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
-       $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.
-    #
-    $xfer = BackupPC::Xfer::Smb->new($bpc);
+$xfer = BackupPC::Xfer::create($Conf{XferMethod}, $bpc);
+if ( !defined($xfer) ) {
+    my $errStr = BackupPC::Xfer::errStr();
+    UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
+    $stat{hostError} = $errStr;
+    exit(RestoreCleanup($client));
 }
 }
+
 my $useTar = $xfer->useTar;
 
 if ( $useTar ) {
 my $useTar = $xfer->useTar;
 
 if ( $useTar ) {
@@ -487,7 +461,7 @@ sub CorrectHostCheck
                || $Conf{NmbLookupCmd} eq "" );
     my($netBiosHost, $netBiosUser) = $bpc->NetBiosInfoGet($hostIP);
     return "host $host has mismatching netbios name $netBiosHost"
                || $Conf{NmbLookupCmd} eq "" );
     my($netBiosHost, $netBiosUser) = $bpc->NetBiosInfoGet($hostIP);
     return "host $host has mismatching netbios name $netBiosHost"
-            if ( $netBiosHost ne $host );
+            if ( lc($netBiosHost) ne lc(substr($host, 0, 15)) );
     return;
 }
 
     return;
 }