projects
/
BackupPC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed some typos.
[BackupPC.git]
/
bin
/
BackupPC_archive
diff --git
a/bin/BackupPC_archive
b/bin/BackupPC_archive
index
ebdc103
..
e1e9900
100644
(file)
--- a/
bin/BackupPC_archive
+++ b/
bin/BackupPC_archive
@@
-8,10
+8,10
@@
# Usage: BackupPC_archive <user> <archiveclient> <reqFileName>
#
# AUTHOR
# Usage: BackupPC_archive <user> <archiveclient> <reqFileName>
#
# AUTHOR
-#
Craig Barratt <cbarratt@users.sourceforge.net>
+#
Josh Marshall
#
# COPYRIGHT
#
# COPYRIGHT
-# Copyright (C) 2001-200
3
Craig Barratt
+# Copyright (C) 2001-200
4
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
2.1.0_CVS, released 8 Feb 2004
.
+# Version
3.0.0alpha, released 23 Jan 2006
.
#
# See http://backuppc.sourceforge.net.
#
#
# See http://backuppc.sourceforge.net.
#
@@
-139,7
+139,10
@@
if ( $Conf{ClientNameAlias} ne "" ) {
#
# Setup file extension for compression and open ArchiveLOG output file
#
#
# 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});
my $fileExt = $Conf{CompressLevel} > 0 ? ".z" : "";
my $ArchiveLOG = BackupPC::FileZIO->open("$Dir/ArchiveLOG$fileExt", 1,
$Conf{CompressLevel});
@@
-154,6
+157,10
@@
local(*RH, *WH);
# Run an optional pre-archive command
#
UserCommandRun("ArchivePreUserCmd");
# Run an optional pre-archive command
#
UserCommandRun("ArchivePreUserCmd");
+if ( $? && $Conf{UserCmdCheckStatus} ) {
+ $stat{hostError} = "ArchivePreUserCmd returned error status $?";
+ exit(ArchiveCleanup($client));
+}
$NeedPostCmd = 1;
$xfer = BackupPC::Xfer::Archive->new($bpc);
$NeedPostCmd = 1;
$xfer = BackupPC::Xfer::Archive->new($bpc);
@@
-241,12
+248,18
@@
sub ArchiveCleanup
if ( !$stat{xferOK} ) {
#
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 ) {
#
if ( @xferPid ) {
- kill($bpc->sigName2num("INT"), @xferPid);
+ foreach my $pid ( @xferPid ) {
+ kill($bpc->sigName2num("INT"), -$pid);
+ }
sleep(1);
sleep(1);
- kill($bpc->sigName2num("KILL"), @xferPid);
+ foreach my $pid ( @xferPid ) {
+ kill($bpc->sigName2num("KILL"), -$pid);
+ }
}
}
}
}
@@
-262,7
+275,13
@@
sub ArchiveCleanup
#
# Run an optional post-archive command
#
#
# Run an optional post-archive command
#
- UserCommandRun("ArchivePostUserCmd") if ( $NeedPostCmd );
+ if ( $NeedPostCmd ) {
+ UserCommandRun("ArchivePostUserCmd");
+ if ( $? && $Conf{UserCmdCheckStatus} ) {
+ $stat{hostError} = "RestorePreUserCmd returned error status $?";
+ $stat{xferOK} = 0;
+ }
+ }
rename("$Dir/ArchiveLOG$fileExt", "$Dir/ArchiveLOG.$lastNum$fileExt");
rename("$Dir/$reqFileName", "$Dir/ArchiveInfo.$lastNum");
rename("$Dir/ArchiveLOG$fileExt", "$Dir/ArchiveLOG.$lastNum$fileExt");
rename("$Dir/$reqFileName", "$Dir/ArchiveInfo.$lastNum");
@@
-272,11
+291,7
@@
sub ArchiveCleanup
# If the archive failed, clean up
#
if ( !$stat{xferOK} ) {
# 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 "" );
$stat{hostError} = $stat{lastOutputLine} if ( $stat{hostError} eq "" );
- sleep(2);
$stat{hostAbort} = 1;
$ArchiveLOG->write(\"Archive failed: $stat{hostError}")
if ( defined($ArchiveLOG) );
$stat{hostAbort} = 1;
$ArchiveLOG->write(\"Archive failed: $stat{hostError}")
if ( defined($ArchiveLOG) );
@@
-336,9
+351,9
@@
sub pidHandler
#
sub UserCommandRun
{
#
sub UserCommandRun
{
- my($
t
ype) = @_;
+ my($
cmdT
ype) = @_;
- return if ( !defined($Conf{$
t
ype}) );
+ return if ( !defined($Conf{$
cmdT
ype}) );
my $vars = {
xfer => $xfer,
client => $client,
my $vars = {
xfer => $xfer,
client => $client,
@@
-358,10
+373,11
@@
sub UserCommandRun
XferLOG => $ArchiveLOG,
stat => \%stat,
xferOK => $stat{xferOK} || 0,
XferLOG => $ArchiveLOG,
stat => \%stat,
xferOK => $stat{xferOK} || 0,
- type => $type,
+ type => "archive",
+ cmdType => $cmdType,
};
};
- my $cmd = $bpc->cmdVarSubstitute($Conf{$
t
ype}, $vars);
- $ArchiveLOG->write(\"Executing $
t
ype: @$cmd\n");
+ my $cmd = $bpc->cmdVarSubstitute($Conf{$
cmdT
ype}, $vars);
+ $ArchiveLOG->write(\"Executing $
cmdT
ype: @$cmd\n");
#
# Run the user's command, dumping the stdout/stderr into the
# Xfer log file. Also supply the optional $vars and %Conf in
#
# Run the user's command, dumping the stdout/stderr into the
# Xfer log file. Also supply the optional $vars and %Conf in