mirror of
https://github.com/deajan/obackup.git
synced 2024-11-14 03:33:41 +01:00
Added an option to run after exec cmd on error
This commit is contained in:
parent
9d057ea95f
commit
15d3d98164
@ -1085,15 +1085,24 @@ function TrapQuit {
|
||||
|
||||
if [ $ERROR_ALERT -ne 0 ]; then
|
||||
SendAlert
|
||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
||||
RunAfterHook
|
||||
fi
|
||||
CleanUp
|
||||
Logger "Backup script finished with errors." "ERROR"
|
||||
exitcode=1
|
||||
elif [ $WARN_ALERT -ne 0 ]; then
|
||||
SendAlert
|
||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
||||
RunAfterHook
|
||||
fi
|
||||
CleanUp
|
||||
Logger "Backup script finished with warnings." "WARN"
|
||||
exitcode=2
|
||||
else
|
||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
||||
RunAfterHook
|
||||
fi
|
||||
CleanUp
|
||||
Logger "Backup script finshed." "NOTICE"
|
||||
exitcode=0
|
||||
|
@ -36,15 +36,24 @@ function TrapQuit {
|
||||
|
||||
if [ $ERROR_ALERT -ne 0 ]; then
|
||||
SendAlert
|
||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
||||
RunAfterHook
|
||||
fi
|
||||
CleanUp
|
||||
Logger "Backup script finished with errors." "ERROR"
|
||||
exitcode=1
|
||||
elif [ $WARN_ALERT -ne 0 ]; then
|
||||
SendAlert
|
||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
||||
RunAfterHook
|
||||
fi
|
||||
CleanUp
|
||||
Logger "Backup script finished with warnings." "WARN"
|
||||
exitcode=2
|
||||
else
|
||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
||||
RunAfterHook
|
||||
fi
|
||||
CleanUp
|
||||
Logger "Backup script finshed." "NOTICE"
|
||||
exitcode=0
|
||||
|
@ -1,6 +1,6 @@
|
||||
###### Local / Remote backup script for files & databases
|
||||
###### (C) 2013-2015 by Ozy de Jong (www.netpower.fr)
|
||||
###### obackup v2.x config file rev 2016032501
|
||||
###### obackup v2.x config file rev 2016040601
|
||||
|
||||
###### GENERAL BACKUP OPTIONS
|
||||
|
||||
@ -198,3 +198,6 @@ MAX_EXEC_TIME_PER_CMD_AFTER=0
|
||||
|
||||
## Stops whole backup execution if one of the above commands fail
|
||||
STOP_ON_CMD_ERROR=no
|
||||
|
||||
## Run local and remote after backup cmd's even on failure
|
||||
RUN_AFTER_CMD_ON_ERROR=no
|
||||
|
@ -1013,15 +1013,24 @@ function TrapQuit {
|
||||
|
||||
if [ $ERROR_ALERT -ne 0 ]; then
|
||||
SendAlert
|
||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
||||
RunAfterHook
|
||||
fi
|
||||
CleanUp
|
||||
Logger "Backup script finished with errors." "ERROR"
|
||||
exitcode=1
|
||||
elif [ $WARN_ALERT -ne 0 ]; then
|
||||
SendAlert
|
||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
||||
RunAfterHook
|
||||
fi
|
||||
CleanUp
|
||||
Logger "Backup script finished with warnings." "WARN"
|
||||
exitcode=2
|
||||
else
|
||||
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
|
||||
RunAfterHook
|
||||
fi
|
||||
CleanUp
|
||||
Logger "Backup script finshed." "NOTICE"
|
||||
exitcode=0
|
||||
|
@ -6,7 +6,7 @@ AUTHOR="(C) 2015 by Orsiris \"Ozy\" de Jong"
|
||||
CONTACT="http://www.netpower.fr/obacup - ozy@netpower.fr"
|
||||
OLD_PROGRAM_VERSION="v1.x"
|
||||
NEW_PROGRAM_VERSION="v2.x"
|
||||
PROGRAM_BUILD=2016033101
|
||||
PROGRAM_BUILD=2016040601
|
||||
|
||||
function Usage {
|
||||
echo "$PROGRAM $PROGRAM_BUILD"
|
||||
@ -43,8 +43,8 @@ function RewriteConfigFiles {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Backing up [$config_file] as [$config_file.v1.x.save]"
|
||||
cp --preserve "$config_file" "$config_file.v1.x.save"
|
||||
echo "Backing up [$config_file] as [$config_file.save]"
|
||||
cp --preserve "$config_file" "$config_file.save"
|
||||
if [ $? != 0 ]; then
|
||||
echo "Cannot backup config file."
|
||||
exit 1
|
||||
@ -168,6 +168,11 @@ function RewriteConfigFiles {
|
||||
if ! grep "^STOP_ON_CMD_ERROR=" "$config_file" > /dev/null; then
|
||||
sed -i '/^MAX_EXEC_TIME_PER_CMD_AFTER=*/a STOP_ON_CMD_ERROR=no' "$config_file"
|
||||
fi
|
||||
|
||||
if ! grep "^RUN_AFTER_CMD_ON_ERROR=" "$config_file" > /dev/null; then
|
||||
sed -i '/^STOP_ON_CMD_ERROR=*/a RUN_AFTER_CMD_ON_ERROR=no' "$config_file"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
if [ "$1" != "" ] && [ -f "$1" ] && [ -w "$1" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user