X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_restore;h=5843a01880543fb7b21bf58cff0eda733b452869;hp=1186cac89294516bbf548a4d272593041f017cac;hb=refs%2Ftags%2Fv2_1_0beta2;hpb=74dc9d456332757127d5eda4ce32f29377133fa2 diff --git a/bin/BackupPC_restore b/bin/BackupPC_restore index 1186cac..5843a01 100755 --- a/bin/BackupPC_restore +++ b/bin/BackupPC_restore @@ -1,4 +1,4 @@ -#!/bin/perl -T +#!/bin/perl #============================================================= -*-perl-*- # # BackupPC_restore: Restore files to a client. @@ -11,7 +11,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001 Craig Barratt +# Copyright (C) 2001-2003 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 @@ -29,13 +29,14 @@ # #======================================================================== # -# Version 2.0.0beta3, released 1 Jun 2003. +# Version 2.1.0beta2, released 23 May 2004. # # See http://backuppc.sourceforge.net. # #======================================================================== use strict; +no utf8; use lib "/usr/local/BackupPC/lib"; use BackupPC::Lib; use BackupPC::FileZIO; @@ -263,6 +264,7 @@ my $xferArgs = { pipeWH => *WH, XferLOG => $RestoreLOG, XferMethod => $Conf{XferMethod}, + logLevel => $Conf{XferLogLevel}, bkupSrcHost => $RestoreReq{hostSrc}, bkupSrcShare => $RestoreReq{shareSrc}, bkupSrcNum => $RestoreReq{num}, @@ -320,6 +322,7 @@ if ( $useTar ) { $stat{hostError} = "Can't fork to run tar"; exit(RestoreCleanup($client)); } + binmode(TAR); if ( !$tarPid ) { # # This is the tarCreate child. Clone STDERR to STDOUT, @@ -330,6 +333,7 @@ if ( $useTar ) { open(STDERR, ">&STDOUT"); close(STDOUT); open(STDOUT, ">&WH"); + alarm(0); exec("$BinDir/BackupPC_tarCreate", @tarArgs); print(LOG $bpc->timeStamp, "can't exec $BinDir/BackupPC_tarCreate\n"); # FIX: need to cleanup xfer @@ -490,17 +494,17 @@ sub RestoreCleanup # kill off the tranfer program, first nicely then forcefully # if ( @xferPid ) { - kill(2, @xferPid); + kill($bpc->sigName2num("INT"), @xferPid); sleep(1); - kill(9, @xferPid); + kill($bpc->sigName2num("KILL"), @xferPid); } # # kill off the tar process, first nicely then forcefully # if ( $tarPid > 0 ) { - kill(2, $tarPid); + kill($bpc->sigName2num("INT"), $tarPid); sleep(1); - kill(9, $tarPid); + kill($bpc->sigName2num("KILL"), $tarPid); } } @@ -612,6 +616,7 @@ sub UserCommandRun return if ( !defined($Conf{$type}) ); my $vars = { xfer => $xfer, + client => $client, host => $host, hostIP => $hostIP, share => $RestoreReq{shareDest}, @@ -622,7 +627,8 @@ sub UserCommandRun moreUsers => $Hosts->{$client}{moreUsers}, XferLOG => $RestoreLOG, stat => \%stat, - xferOK => $stat{xferOK}, + xferOK => $stat{xferOK} || 0, + hostError => $stat{hostError}, type => $type, bkupSrcHost => $RestoreReq{hostSrc}, bkupSrcShare => $RestoreReq{shareSrc},