-#!/bin/perl -T
+#!/bin/perl
#============================================================= -*-perl-*-
#
# BackupPC_restore: Restore files to a client.
# Craig Barratt <cbarratt@users.sourceforge.net>
#
# 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
#
#========================================================================
#
-# Version 2.0.0beta3, released 1 Jun 2003.
+# Version 2.1.0, released 20 Jun 2004.
#
# See http://backuppc.sourceforge.net.
#
#========================================================================
use strict;
+no utf8;
use lib "/usr/local/BackupPC/lib";
use BackupPC::Lib;
use BackupPC::FileZIO;
#
# 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});
pipeWH => *WH,
XferLOG => $RestoreLOG,
XferMethod => $Conf{XferMethod},
+ logLevel => $Conf{XferLogLevel},
bkupSrcHost => $RestoreReq{hostSrc},
bkupSrcShare => $RestoreReq{shareSrc},
bkupSrcNum => $RestoreReq{num},
$stat{hostError} = "Can't fork to run tar";
exit(RestoreCleanup($client));
}
+ binmode(TAR);
if ( !$tarPid ) {
#
# This is the tarCreate child. Clone STDERR to STDOUT,
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
# 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);
}
}
#
sub UserCommandRun
{
- my($type) = @_;
+ my($cmdType) = @_;
- return if ( !defined($Conf{$type}) );
+ return if ( !defined($Conf{$cmdType}) );
my $vars = {
xfer => $xfer,
+ client => $client,
host => $host,
hostIP => $hostIP,
share => $RestoreReq{shareDest},
moreUsers => $Hosts->{$client}{moreUsers},
XferLOG => $RestoreLOG,
stat => \%stat,
- xferOK => $stat{xferOK},
- type => $type,
+ xferOK => $stat{xferOK} || 0,
+ hostError => $stat{hostError},
+ 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