X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_archive;h=e9ed33b8f8605e9a280630f636002990c1c5c9be;hp=8a7683a8b0f9b796dfff8affd3fe3e5dd35a5827;hb=5b3e6091d542c2e7445d5dd511cdf6e20aec8b8d;hpb=79e0593c501fd58046feeca20c315cc4ac283435 diff --git a/bin/BackupPC_archive b/bin/BackupPC_archive index 8a7683a..e9ed33b 100644 --- a/bin/BackupPC_archive +++ b/bin/BackupPC_archive @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0beta2, released 23 May 2004. +# Version 3.0.0alpha, released 23 Jan 2006. # # See http://backuppc.sourceforge.net. # @@ -139,7 +139,10 @@ if ( $Conf{ClientNameAlias} ne "" ) { # # Setup file extension for compression and open ArchiveLOG output file # -$Conf{CompressLevel} = 0 if ( !BackupPC::FileZIO->compOk ); +if ( $Conf{CompressLevel} && !BackupPC::FileZIO->compOk ) { + $stat{hostError} = "Compress::Zlib not found"; + exit(ArchiveCleanup($client)); +} my $fileExt = $Conf{CompressLevel} > 0 ? ".z" : ""; my $ArchiveLOG = BackupPC::FileZIO->open("$Dir/ArchiveLOG$fileExt", 1, $Conf{CompressLevel}); @@ -241,12 +244,18 @@ sub ArchiveCleanup if ( !$stat{xferOK} ) { # - # kill off the tranfer program, first nicely then forcefully + # Kill off the tranfer program, first nicely then forcefully. + # We use negative PIDs to make sure all processes in each + # group get the signal. # if ( @xferPid ) { - kill($bpc->sigName2num("INT"), @xferPid); + foreach my $pid ( @xferPid ) { + kill($bpc->sigName2num("INT"), -$pid); + } sleep(1); - kill($bpc->sigName2num("KILL"), @xferPid); + foreach my $pid ( @xferPid ) { + kill($bpc->sigName2num("KILL"), -$pid); + } } } @@ -272,11 +281,7 @@ sub ArchiveCleanup # If the archive failed, clean up # if ( !$stat{xferOK} ) { - # - # wait a short while and see if the system is still alive - # $stat{hostError} = $stat{lastOutputLine} if ( $stat{hostError} eq "" ); - sleep(2); $stat{hostAbort} = 1; $ArchiveLOG->write(\"Archive failed: $stat{hostError}") if ( defined($ArchiveLOG) ); @@ -336,9 +341,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, @@ -358,10 +363,11 @@ sub UserCommandRun XferLOG => $ArchiveLOG, stat => \%stat, xferOK => $stat{xferOK} || 0, - type => $type, + type => "archive", + cmdType => $cmdType, }; - my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars); - $ArchiveLOG->write(\"Executing $type: @$cmd\n"); + my $cmd = $bpc->cmdVarSubstitute($Conf{$cmdType}, $vars); + $ArchiveLOG->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