(I originally sent this to the user mailing list, not knowing that a
development list exists).
Hello,
the attached patch introduces finer-grained check of pre/post user
command failure. Currently this is controlled with
$Conf{UserCmdCheckStatus} which is an all-or-nothing switch, so if it's set
to 1 and a non-critical script fails, the whole backup fails. However,
there may be cases where that is not wanted or needed, for example a
DumpPostUserCmd may be some email notification or other non-critical action
that may fail even if the actual xfer was ok, without the need to
invalidate the dump and throw everything away. In general, one may have
various pre/post commands that are ran when the dump is performed, some of
which are critical and some of which are not.
So this patch introduces new configuration options like
$Conf{DumpPreUserCmdCheckStatus}, $Conf{DumpPostUserCmdCheckStatus} etc.
that can be individually set to fine-tune failure behavior. They are
evaluated only when the main switch $Conf{CmdCheckStatus} is set to 0;
if $Conf{UserCmdCheckStatus} is set to 1, it still has priority over any
other option, so the patch should be backwards compatible with existing
configurations without breaking anything.
The patch is against 3.3.0.
Any comment or criticism is welcome.
Regards,
--
D.
diff -urN BackupPC-3.3.0-orig/bin/BackupPC_archive BackupPC-3.3.0/bin/BackupPC_archive
--- BackupPC-3.3.0-orig/bin/BackupPC_archive 2013-04-14 22:43:32.000000000 +0200
+++ BackupPC-3.3.0/bin/BackupPC_archive 2013-09-11 12:48:43.000000000 +0200
@@ -178,7 +178,7 @@
# Run an optional pre-archive command
#
UserCommandRun("ArchivePreUserCmd");
-if ( $? && $Conf{UserCmdCheckStatus} ) {
+if ( $? && ( $Conf{UserCmdCheckStatus} || $Conf{ArchivePreUserCmdCheckStatus} ) ) {
$stat{hostError} = "ArchivePreUserCmd returned error status $?";
exit(ArchiveCleanup($client));
}
@@ -298,7 +298,7 @@
#
if ( $NeedPostCmd ) {
UserCommandRun("ArchivePostUserCmd");
- if ( $? && $Conf{UserCmdCheckStatus} ) {
+ if ( $? && ( $Conf{UserCmdCheckStatus} || $Conf{ArchivePostUserCmdCheckStatus} ) ) {
$stat{hostError} = "RestorePreUserCmd returned error status $?";
$stat{xferOK} = 0;
}
diff -urN BackupPC-3.3.0-orig/bin/BackupPC_dump BackupPC-3.3.0/bin/BackupPC_dump
--- BackupPC-3.3.0-orig/bin/BackupPC_dump 2013-04-14 22:43:32.000000000 +0200
+++ BackupPC-3.3.0/bin/BackupPC_dump 2013-09-11 12:47:21.000000000 +0200
@@ -611,7 +611,7 @@
# Run an optional pre-dump command
#
UserCommandRun("DumpPreUserCmd");
-if ( $? && $Conf{UserCmdCheckStatus} ) {
+if ( $? && ( $Conf{UserCmdCheckStatus} || $Conf{DumpPreUserCmdCheckStatus} ) ) {
print(LOG $bpc->timeStamp,
"DumpPreUserCmd returned error status $?... exiting\n");
$XferLOG->write(\"DumpPreUserCmd returned error status $?... exiting\n");
@@ -646,7 +646,7 @@
$shareDuplicate->{$shareName} = 1;
UserCommandRun("DumpPreShareCmd", $shareName);
- if ( $? && $Conf{UserCmdCheckStatus} ) {
+ if ( $? && ( $Conf{UserCmdCheckStatus} || $Conf{DumpPreShareCmdCheckStatus} ) ) {
print(LOG $bpc->timeStamp,
"DumpPreShareCmd returned error status $?... exiting\n");
UserCommandRun("DumpPostUserCmd") if ( $NeedPostCmd );
@@ -892,7 +892,7 @@
if ( $NeedPostCmd ) {
UserCommandRun("DumpPostShareCmd", $shareName);
- if ( $? && $Conf{UserCmdCheckStatus} ) {
+ if ( $? && ( $Conf{UserCmdCheckStatus} || $Conf{DumpPostShareCmdCheckStatus} ) ) {
print(LOG $bpc->timeStamp,
"DumpPostShareCmd returned error status $?... exiting\n");
$stat{hostError} = "DumpPostShareCmd returned error status $?";
@@ -957,7 +957,7 @@
}
UserCommandRun("DumpPostUserCmd") if ( $NeedPostCmd );
-if ( $? && $Conf{UserCmdCheckStatus} ) {
+if ( $? && ( $Conf{UserCmdCheckStatus} || $Conf{DumpPostUserCmdCheckStatus} ) ) {
print(LOG $bpc->timeStamp,
"DumpPostUserCmd returned error status $?... exiting\n");
$stat{hostError} = "DumpPostUserCmd returned error status $?";
diff -urN BackupPC-3.3.0-orig/bin/BackupPC_restore BackupPC-3.3.0/bin/BackupPC_restore
--- BackupPC-3.3.0-orig/bin/BackupPC_restore 2013-04-14 22:43:32.000000000 +0200
+++ BackupPC-3.3.0/bin/BackupPC_restore 2013-09-11 12:49:30.000000000 +0200
@@ -227,7 +227,7 @@
# Run an optional pre-restore command
#
UserCommandRun("RestorePreUserCmd");
-if ( $? && $Conf{UserCmdCheckStatus} ) {
+if ( $? && ( $Conf{UserCmdCheckStatus} || $Conf{RestorePreUserCmdCheckStatus}) ) {
$stat{hostError} = "RestorePreUserCmd returned error status $?";
exit(RestoreCleanup($client));
}
@@ -544,7 +544,7 @@
#
if ( $NeedPostCmd ) {
UserCommandRun("RestorePostUserCmd");
- if ( $? && $Conf{UserCmdCheckStatus} ) {
+ if ( $? && ( $Conf{UserCmdCheckStatus} || $Conf{RestorePostUserCmdCheckStatus} ) ) {
$stat{hostError} = "RestorePostUserCmd returned error status $?";
$stat{xferOK} = 0;
}
diff -urN BackupPC-3.3.0-orig/conf/config.pl BackupPC-3.3.0/conf/config.pl
--- BackupPC-3.3.0-orig/conf/config.pl 2013-04-14 22:43:32.000000000 +0200
+++ BackupPC-3.3.0/conf/config.pl 2013-09-11 12:53:20.000000000 +0200
@@ -1838,6 +1838,27 @@
$Conf{UserCmdCheckStatus} = 0;
#
+# Individual pre/post commands can also be checked, for example
+# you may want to abort the backup if the DumpPreUserCmd fails,
+# but keep it if the DumpPostUserCmd fails (eg because it's just
+# an email notification or other non-critical activity, which
+# can fail without having to throw the backup away).
+#
+# If $Conf{UserCmdCheckStatus} above is set to 1, exit status
+# of any pre/post command is *always* checked, regardless of the
+# settings below; if you want to check individual commands, set
+# $Conf{UserCmdCheckStatus} to 0 and use the configuration
+# options below, whose names should be self-explanatory.
+$Conf{DumpPreUserCmdCheckStatus} = 0;
+$Conf{DumpPostUserCmdCheckStatus} = 0;
+$Conf{DumpPreShareCmdCheckStatus} = 0;
+$Conf{DumpPostShareCmdCheckStatus} = 0;
+$Conf{ArchivePreUserCmdCheckStatus} = 0;
+$Conf{ArchivePostUserCmdCheckStatus} = 0;
+$Conf{RestorePreUserCmdCheckStatus} = 0;
+$Conf{RestorePostUserCmdCheckStatus} = 0;
+
+#
# Override the client's host name. This allows multiple clients
# to all refer to the same physical host. This should only be
# set in the per-PC config file and is only used by BackupPC at
@@ -2180,96 +2201,104 @@
# sorts of bad things.
#
$Conf{CgiUserConfigEdit} = {
- FullPeriod => 1,
- IncrPeriod => 1,
- FullKeepCnt => 1,
- FullKeepCntMin => 1,
- FullAgeMax => 1,
- IncrKeepCnt => 1,
- IncrKeepCntMin => 1,
- IncrAgeMax => 1,
- IncrLevels => 1,
- IncrFill => 1,
- PartialAgeMax => 1,
- RestoreInfoKeepCnt => 1,
- ArchiveInfoKeepCnt => 1,
- BackupFilesOnly => 1,
- BackupFilesExclude => 1,
- BackupsDisable => 1,
- BlackoutBadPingLimit => 1,
- BlackoutGoodCnt => 1,
- BlackoutPeriods => 1,
- BackupZeroFilesIsFatal => 1,
- ClientCharset => 1,
- ClientCharsetLegacy => 1,
- XferMethod => 1,
- XferLogLevel => 1,
- SmbShareName => 1,
- SmbShareUserName => 1,
- SmbSharePasswd => 1,
- SmbClientFullCmd => 0,
- SmbClientIncrCmd => 0,
- SmbClientRestoreCmd => 0,
- TarShareName => 1,
- TarFullArgs => 1,
- TarIncrArgs => 1,
- TarClientCmd => 0,
- TarClientRestoreCmd => 0,
- TarClientPath => 0,
- RsyncShareName => 1,
- RsyncdClientPort => 1,
- RsyncdPasswd => 1,
- RsyncdUserName => 1,
- RsyncdAuthRequired => 1,
- RsyncCsumCacheVerifyProb => 1,
- RsyncArgs => 1,
- RsyncArgsExtra => 1,
- RsyncRestoreArgs => 1,
- RsyncClientCmd => 0,
- RsyncClientRestoreCmd => 0,
- RsyncClientPath => 0,
- FtpShareName => 1,
- FtpUserName => 1,
- FtpPasswd => 1,
- FtpBlockSize => 1,
- FtpPort => 1,
- FtpTimeout => 1,
- FtpFollowSymlinks => 1,
- FtpRestoreEnabled => 1,
- ArchiveDest => 1,
- ArchiveComp => 1,
- ArchivePar => 1,
- ArchiveSplit => 1,
- ArchiveClientCmd => 0,
- FixedIPNetBiosNameCheck => 1,
- NmbLookupCmd => 0,
- NmbLookupFindHostCmd => 0,
- PingMaxMsec => 1,
- PingCmd => 0,
- ClientTimeout => 1,
- MaxOldPerPCLogFiles => 1,
- CompressLevel => 1,
- ClientNameAlias => 1,
- DumpPreUserCmd => 0,
- DumpPostUserCmd => 0,
- RestorePreUserCmd => 0,
- RestorePostUserCmd => 0,
- ArchivePreUserCmd => 0,
- ArchivePostUserCmd => 0,
- DumpPostShareCmd => 0,
- DumpPreShareCmd => 0,
- UserCmdCheckStatus => 0,
- EMailNotifyMinDays => 1,
- EMailFromUserName => 1,
- EMailAdminUserName => 1,
- EMailUserDestDomain => 1,
- EMailNoBackupEverSubj => 1,
- EMailNoBackupEverMesg => 1,
- EMailNotifyOldBackupDays => 1,
- EMailNoBackupRecentSubj => 1,
- EMailNoBackupRecentMesg => 1,
- EMailNotifyOldOutlookDays => 1,
- EMailOutlookBackupSubj => 1,
- EMailOutlookBackupMesg => 1,
- EMailHeaders => 1,
+ FullPeriod => 1,
+ IncrPeriod => 1,
+ FullKeepCnt => 1,
+ FullKeepCntMin => 1,
+ FullAgeMax => 1,
+ IncrKeepCnt => 1,
+ IncrKeepCntMin => 1,
+ IncrAgeMax => 1,
+ IncrLevels => 1,
+ IncrFill => 1,
+ PartialAgeMax => 1,
+ RestoreInfoKeepCnt => 1,
+ ArchiveInfoKeepCnt => 1,
+ BackupFilesOnly => 1,
+ BackupFilesExclude => 1,
+ BackupsDisable => 1,
+ BlackoutBadPingLimit => 1,
+ BlackoutGoodCnt => 1,
+ BlackoutPeriods => 1,
+ BackupZeroFilesIsFatal => 1,
+ ClientCharset => 1,
+ ClientCharsetLegacy => 1,
+ XferMethod => 1,
+ XferLogLevel => 1,
+ SmbShareName => 1,
+ SmbShareUserName => 1,
+ SmbSharePasswd => 1,
+ SmbClientFullCmd => 0,
+ SmbClientIncrCmd => 0,
+ SmbClientRestoreCmd => 0,
+ TarShareName => 1,
+ TarFullArgs => 1,
+ TarIncrArgs => 1,
+ TarClientCmd => 0,
+ TarClientRestoreCmd => 0,
+ TarClientPath => 0,
+ RsyncShareName => 1,
+ RsyncdClientPort => 1,
+ RsyncdPasswd => 1,
+ RsyncdUserName => 1,
+ RsyncdAuthRequired => 1,
+ RsyncCsumCacheVerifyProb => 1,
+ RsyncArgs => 1,
+ RsyncArgsExtra => 1,
+ RsyncRestoreArgs => 1,
+ RsyncClientCmd => 0,
+ RsyncClientRestoreCmd => 0,
+ RsyncClientPath => 0,
+ FtpShareName => 1,
+ FtpUserName => 1,
+ FtpPasswd => 1,
+ FtpBlockSize => 1,
+ FtpPort => 1,
+ FtpTimeout => 1,
+ FtpFollowSymlinks => 1,
+ FtpRestoreEnabled => 1,
+ ArchiveDest => 1,
+ ArchiveComp => 1,
+ ArchivePar => 1,
+ ArchiveSplit => 1,
+ ArchiveClientCmd => 0,
+ FixedIPNetBiosNameCheck => 1,
+ NmbLookupCmd => 0,
+ NmbLookupFindHostCmd => 0,
+ PingMaxMsec => 1,
+ PingCmd => 0,
+ ClientTimeout => 1,
+ MaxOldPerPCLogFiles => 1,
+ CompressLevel => 1,
+ ClientNameAlias => 1,
+ DumpPreUserCmd => 0,
+ DumpPostUserCmd => 0,
+ RestorePreUserCmd => 0,
+ RestorePostUserCmd => 0,
+ ArchivePreUserCmd => 0,
+ ArchivePostUserCmd => 0,
+ DumpPostShareCmd => 0,
+ DumpPreShareCmd => 0,
+ UserCmdCheckStatus => 0,
+ DumpPreUserCmdCheckStatus => 0;
+ DumpPostUserCmdCheckStatus => 0;
+ DumpPreShareCmdCheckStatus => 0;
+ DumpPostShareCmdCheckStatus => 0;
+ ArchivePreUserCmdCheckStatus => 0;
+ ArchivePostUserCmdCheckStatus => 0;
+ RestorePreUserCmdCheckStatus => 0;
+ RestorePostUserCmdCheckStatus => 0;
+ EMailNotifyMinDays => 1,
+ EMailFromUserName => 1,
+ EMailAdminUserName => 1,
+ EMailUserDestDomain => 1,
+ EMailNoBackupEverSubj => 1,
+ EMailNoBackupEverMesg => 1,
+ EMailNotifyOldBackupDays => 1,
+ EMailNoBackupRecentSubj => 1,
+ EMailNoBackupRecentMesg => 1,
+ EMailNotifyOldOutlookDays => 1,
+ EMailOutlookBackupSubj => 1,
+ EMailOutlookBackupMesg => 1,
+ EMailHeaders => 1,
};
diff -urN BackupPC-3.3.0-orig/doc/BackupPC.pod BackupPC-3.3.0/doc/BackupPC.pod
--- BackupPC-3.3.0-orig/doc/BackupPC.pod 2013-04-14 22:43:32.000000000 +0200
+++ BackupPC-3.3.0/doc/BackupPC.pod 2013-09-11 12:57:04.000000000 +0200
@@ -4441,6 +4441,27 @@
that snapshots or dumps a database which fails because
of some database error.
+=item $Conf{DumpPreUserCmdCheckStatus} = 0;
+=item $Conf{DumpPostUserCmdCheckStatus} = 0;
+=item $Conf{DumpPreShareCmdCheckStatus} = 0;
+=item $Conf{DumpPostShareCmdCheckStatus} = 0;
+=item $Conf{ArchivePreUserCmdCheckStatus} = 0;
+=item $Conf{ArchivePostUserCmdCheckStatus} = 0;
+=item $Conf{RestorePreUserCmdCheckStatus} = 0;
+=item $Conf{RestorePostUserCmdCheckStatus} = 0;
+
+Individual pre/post commands can also be checked, for example
+you may want to abort the backup if the DumpPreUserCmd fails,
+but keep it if the DumpPostUserCmd fails (eg because it's just
+an email notification or other non-critical activity, which
+can fail without having to throw the backup away).
+
+If $Conf{UserCmdCheckStatus} above is set to 1, exit status
+of any pre/post command is *always* checked, regardless of the
+settings below; if you want to check individial commands, set
+$Conf{UserCmdCheckStatus} to 0 and use the configuration
+options above, whose names should be self-explanatory.
+
=item $Conf{ClientNameAlias} = undef;
Override the client's host name. This allows multiple clients
diff -urN BackupPC-3.3.0-orig/lib/BackupPC/CGI/EditConfig.pm BackupPC-3.3.0/lib/BackupPC/CGI/EditConfig.pm
--- BackupPC-3.3.0-orig/lib/BackupPC/CGI/EditConfig.pm 2013-04-14 22:43:32.000000000 +0200
+++ BackupPC-3.3.0/lib/BackupPC/CGI/EditConfig.pm 2013-09-11 12:52:21.000000000 +0200
@@ -357,6 +357,14 @@
{name => "ArchivePreUserCmd"},
{name => "ArchivePostUserCmd"},
{name => "UserCmdCheckStatus"},
+ {name => "DumpPreUserCmdCheckStatus"},
+ {name => "DumpPostUserCmdCheckStatus"},
+ {name => "DumpPreShareCmdCheckStatus"},
+ {name => "DumpPostShareCmdCheckStatus"},
+ {name => "ArchivePreUserCmdCheckStatus"},
+ {name => "ArchivePostUserCmdCheckStatus"},
+ {name => "RestorePreUserCmdCheckStatus"},
+ {name => "RestorePostUserCmdCheckStatus"},
],
},
hosts => {
diff -urN BackupPC-3.3.0-orig/lib/BackupPC/Config/Meta.pm BackupPC-3.3.0/lib/BackupPC/Config/Meta.pm
--- BackupPC-3.3.0-orig/lib/BackupPC/Config/Meta.pm 2013-04-14 22:43:32.000000000 +0200
+++ BackupPC-3.3.0/lib/BackupPC/Config/Meta.pm 2013-09-11 12:51:22.000000000 +0200
@@ -320,8 +320,15 @@
RestorePostUserCmd => {type => "string", undefIfEmpty => 1},
ArchivePreUserCmd => {type => "string", undefIfEmpty => 1},
ArchivePostUserCmd => {type => "string", undefIfEmpty => 1},
- UserCmdCheckStatus => "boolean",
-
+ UserCmdCheckStatus => "boolean",
+ DumpPreUserCmdCheckStatus => "boolean",
+ DumpPostUserCmdCheckStatus => "boolean",
+ DumpPreShareCmdCheckStatus => "boolean",
+ DumpPostShareCmdCheckStatus => "boolean",
+ ArchivePreUserCmdCheckStatus => "boolean",
+ ArchivePostUserCmdCheckStatus => "boolean",
+ RestorePreUserCmdCheckStatus => "boolean",
+ RestorePostUserCmdCheckStatus => "boolean",
ClientNameAlias => {type => "string", undefIfEmpty => 1},
######################################################################
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
BackupPC-devel mailing list
BackupPC-devel@lists.sourceforge.net
List: https://lists.sourceforge.net/lists/listinfo/backuppc-devel
Wiki: http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/