# Josh Marshall
#
# COPYRIGHT
-# Copyright (C) 2001-2004 Craig Barratt
+# Copyright (C) 2001-2007 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.1.0, released 20 Jun 2004.
+# Version 3.1.0, released 25 Nov 2007.
#
# See http://backuppc.sourceforge.net.
#
}
$user = $1 if ( $ARGV[0] =~ /(.+)/ );
$client = $1 if ( $ARGV[1] =~ /(.+)/ );
-if ( $ARGV[2] !~ /^([\w.]+)$/ ) {
+if ( $ARGV[2] !~ /^([\w\.\s-]+)$/ ) {
print("$0: bad reqFileName (arg #3): $ARGV[2]\n");
exit(1);
}
if ( !-f "$Dir/LOCK" ) {
open(LOCK, ">", "$Dir/LOCK") && close(LOCK);
}
-open(LOG, ">>", "$Dir/LOG");
-select(LOG); $| = 1; select(STDOUT);
+my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+my $logPath = sprintf("$Dir/LOG.%02d%04d", $mon + 1, $year + 1900);
+
+if ( !-f $logPath ) {
+ #
+ # Compress and prune old log files
+ #
+ my $lastLog = $Conf{MaxOldPerPCLogFiles} - 1;
+ foreach my $file ( $bpc->sortedPCLogFiles($client) ) {
+ if ( $lastLog <= 0 ) {
+ unlink($file);
+ next;
+ }
+ $lastLog--;
+ next if ( $file =~ /\.z$/ || !$Conf{CompressLevel} );
+ BackupPC::FileZIO->compressCopy($file,
+ "$file.z",
+ undef,
+ $Conf{CompressLevel}, 1);
+ }
+}
+open(LOG, ">>", $logPath);
+select(LOG); $| = 1; select(STDOUT);
#
# Read the request file
# 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);
#
# 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");