#
#========================================================================
#
-# Version 2.0.0_CVS, released 18 Jan 2003.
+# Version 2.0.0beta2, released 13 Apr 2003.
#
# See http://backuppc.sourceforge.net.
#
my $startTime = time();
-my $Hosts = $bpc->HostInfoRead();
+my $Hosts = $bpc->HostInfoRead($client);
my $Dir = "$TopDir/pc/$client";
-my $xferPid = -1;
+my @xferPid = ();
my $tarPid = -1;
#
open(LOG, ">>", "$Dir/LOG");
select(LOG); $| = 1; select(STDOUT);
+
#
# Read the request file
#
pathHdrSrc => $RestoreReq{pathHdrSrc},
pathHdrDest => $RestoreReq{pathHdrDest},
fileList => $RestoreReq{fileList},
+ pidHandler => \&pidHandler,
};
$xfer->args($xferArgs);
#
close(WH);
- $xferPid = $xfer->xferPid;
- print(LOG $bpc->timeStamp, $logMsg, " (tarPid=$tarPid, xferPid=$xferPid)\n");
- print("started restore, tarPid=$tarPid, xferPid=$xferPid\n");
+ @xferPid = $xfer->xferPid;
+
+ print(LOG $bpc->timeStamp, $logMsg, "\n");
+ print("started_restore\n");
+
+ pidHandler(@xferPid);
#
# Parse the output of the transfer program and BackupPC_tarCreate
#
# otherwise the xfer module does everything for us
#
- print(LOG $bpc->timeStamp, "Starting restore (tarPid=-1, xferPid=-1)\n");
- print("started restore, tarPid=-1, xferPid=-1\n");
+ print(LOG $bpc->timeStamp, "Starting restore\n");
+ print("started_restore\n");
($tarCreateFileCnt, $tarCreateByteCnt,
$tarCreateErrCnt, $tarCreateErr) = $xfer->run();
}
sub CorrectHostCheck
{
my($hostIP, $host) = @_;
- return if ( $hostIP eq $host && !$Conf{FixedIPNetBiosNameCheck} );
+ return if ( $hostIP eq $host && !$Conf{FixedIPNetBiosNameCheck}
+ || $Conf{NmbLookupCmd} eq "" );
my($netBiosHost, $netBiosUser) = $bpc->NetBiosInfoGet($hostIP);
return "host $host has mismatching netbios name $netBiosHost"
if ( $netBiosHost ne $host );
# Note: needs to be tested for each kind of XferMethod
#
print(LOG $bpc->timeStamp, "cleaning up after signal $signame\n");
- if ( $xferPid > 0 ) {
- if ( kill(2, $xferPid) <= 0 ) {
- sleep(1);
- kill(9, $xferPid);
- }
+ if ( @xferPid ) {
+ kill(2, @xferPid);
+ sleep(1);
+ kill(9, @xferPid);
}
if ( $tarPid > 0 ) {
- if ( kill(2, $tarPid) <= 0 ) {
- sleep(1);
- kill(9, $tarPid);
- }
+ kill(2, $tarPid);
+ sleep(1);
+ kill(9, $tarPid);
}
$stat{xferOK} = 0;
$stat{hostError} = "aborted by signal $signame";
#
# kill off the tranfer program, first nicely then forcefully
#
- kill(2, $xferPid) if ( $xferPid > 0 );
- sleep(1);
- kill(9, $xferPid) if ( $xferPid > 0 );
+ if ( @xferPid ) {
+ kill(2, @xferPid);
+ sleep(1);
+ kill(9, @xferPid);
+ }
#
# kill off the tar process, first nicely then forcefully
#
- kill(2, $tarPid) if ( $tarPid > 0 );
- sleep(1);
- kill(9, $tarPid) if ( $tarPid > 0 );
+ if ( $tarPid > 0 ) {
+ kill(2, $tarPid);
+ sleep(1);
+ kill(9, $tarPid);
+ }
}
my $lastNum = -1;
}
}
+#
+# The Xfer method might tell us from time to time about processes
+# it forks. We tell BackupPC about this (for status displays) and
+# keep track of the pids in case we cancel the backup
+#
+sub pidHandler
+{
+ @xferPid = @_;
+ @xferPid = grep(/./, @xferPid);
+ return if ( !@xferPid && $tarPid < 0 );
+ my @pids = @xferPid;
+ push(@pids, $tarPid) if ( $tarPid > 0 );
+ my $str = join(",", @pids);
+ $XferLOG->write(\"Xfer PIDs are now $str\n") if ( defined($XferLOG) );
+ print("xferPids $str\n");
+}
+
#
# Run an optional pre- or post-dump command
#
XferMethod => $Conf{XferMethod},
sshPath => $Conf{SshPath},
LOG => *LOG,
+ user => $Hosts->{$client}{user},
+ moreUsers => $Hosts->{$client}{moreUsers},
XferLOG => $RestoreLOG,
stat => \%stat,
xferOK => $stat{xferOK},