Fixed cleanup launches even if DEBUG=yes

This commit is contained in:
deajan 2013-07-17 11:31:21 +02:00
parent 8d3f66316d
commit 376cb9e0b3
1 changed files with 29 additions and 25 deletions

View File

@ -3,7 +3,7 @@
###### Remote (or local) backup script for files & databases ###### Remote (or local) backup script for files & databases
###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr) ###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr)
OBACKUP_VERSION=1.84RC1 OBACKUP_VERSION=1.84RC1
OBACKUP_BUILD=1607201301 OBACKUP_BUILD=1707201301
DEBUG=no DEBUG=no
SCRIPT_PID=$$ SCRIPT_PID=$$
@ -65,13 +65,23 @@ function TrapError
function TrapStop function TrapStop
{ {
LogError " /!\ WARNING: Manual exit of backup script. Backups may be in inconsistent state." LogError " /!\ WARNING: Manual exit of backup script. Backups may be in inconsistent state."
if [ "$DEBUG" == "no" ] CleanUp
then
CleanUp
fi
exit 1 exit 1
} }
function TrapQuit
{
if [ $error_alert -ne 0 ]
then
SendAlert
LogError "Backup script finished with errors."
exit 1
else
Log "Backup script finshed."
exit 0
fi
}
function Spinner function Spinner
{ {
if [ $silent -eq 1 ] if [ $silent -eq 1 ]
@ -124,15 +134,18 @@ function EscapeSpaces
function CleanUp function CleanUp
{ {
rm -f /dev/shm/obackup_dblist_$SCRIPT_PID if [ "$DEBUG" != "yes" ]
rm -f /dev/shm/obackup_local_sql_storage_$SCRIPT_PID then
rm -f /dev/shm/obackup_local_file_storage_$SCRIPT_PID rm -f /dev/shm/obackup_dblist_$SCRIPT_PID
rm -f /dev/shm/obackup_dirs_recurse_list_$SCRIPT_PID rm -f /dev/shm/obackup_local_sql_storage_$SCRIPT_PID
rm -f /dev/shm/obackup_fsize_$SCRIPT_PID rm -f /dev/shm/obackup_local_file_storage_$SCRIPT_PID
rm -f /dev/shm/obackup_rsync_output_$SCRIPT_PID rm -f /dev/shm/obackup_dirs_recurse_list_$SCRIPT_PID
rm -f /dev/shm/obackup_config_$SCRIPT_PID rm -f /dev/shm/obackup_fsize_$SCRIPT_PID
rm -f /dev/shm/obackup_run_local_$SCRIPT_PID rm -f /dev/shm/obackup_rsync_output_$SCRIPT_PID
rm -f /dev/shm/obackup_run_remote_$SCRIPT_PID rm -f /dev/shm/obackup_config_$SCRIPT_PID
rm -f /dev/shm/obackup_run_local_$SCRIPT_PID
rm -f /dev/shm/obackup_run_remote_$SCRIPT_PID
fi
} }
function SendAlert function SendAlert
@ -923,7 +936,8 @@ function Init
set -o pipefail set -o pipefail
set -o errtrace set -o errtrace
trap TrapStop SIGINT SIGQUIT trap TrapStop SIGINT SIGQUIT SIGKILL SIGTERM SIGHUP
trap TrapQuit EXIT
if [ "$DEBUG" == "yes" ] if [ "$DEBUG" == "yes" ]
then then
trap 'TrapError ${LINENO} $?' ERR trap 'TrapError ${LINENO} $?' ERR
@ -1073,13 +1087,3 @@ then
else else
LogError "Environment not suitable to run obackup." LogError "Environment not suitable to run obackup."
fi fi
if [ $error_alert -ne 0 ]
then
SendAlert
LogError "Backup script finished with errors."
exit 1
else
Log "Backup script finshed."
exit 0
fi