1
0
mirror of https://github.com/deajan/obackup.git synced 2024-11-15 04:03:41 +01:00

Fixed ExecTasks call syntax

This commit is contained in:
deajan 2018-01-19 16:08:05 +01:00
parent 2ba247e2eb
commit b4a7f3018a

View File

@ -7,7 +7,7 @@ PROGRAM="obackup"
AUTHOR="(C) 2013-2017 by Orsiris de Jong" AUTHOR="(C) 2013-2017 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
PROGRAM_VERSION=2.1-beta4 PROGRAM_VERSION=2.1-beta4
PROGRAM_BUILD=2018010302 PROGRAM_BUILD=2018011901
IS_STABLE=no IS_STABLE=no
#### Execution order #__WITH_PARANOIA_DEBUG #### Execution order #__WITH_PARANOIA_DEBUG
@ -259,7 +259,7 @@ function _ListDatabasesLocal {
sqlCmd="mysql -u $SQL_USER -Bse 'SELECT table_schema, round(sum( data_length + index_length ) / 1024) FROM information_schema.TABLES GROUP by table_schema;' > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP 2>&1" sqlCmd="mysql -u $SQL_USER -Bse 'SELECT table_schema, round(sum( data_length + index_length ) / 1024) FROM information_schema.TABLES GROUP by table_schema;' > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP 2>&1"
Logger "Launching command [$sqlCmd]." "DEBUG" Logger "Launching command [$sqlCmd]." "DEBUG"
eval "$sqlCmd" & eval "$sqlCmd" &
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
Logger "Listing databases succeeded." "NOTICE" Logger "Listing databases succeeded." "NOTICE"
@ -285,7 +285,7 @@ function _ListDatabasesRemote {
sqlCmd="$SSH_CMD \"env _REMOTE_TOKEN=$_REMOTE_TOKEN mysql -u $SQL_USER -Bse 'SELECT table_schema, round(sum( data_length + index_length ) / 1024) FROM information_schema.TABLES GROUP by table_schema;'\" > \"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP\" 2>&1" sqlCmd="$SSH_CMD \"env _REMOTE_TOKEN=$_REMOTE_TOKEN mysql -u $SQL_USER -Bse 'SELECT table_schema, round(sum( data_length + index_length ) / 1024) FROM information_schema.TABLES GROUP by table_schema;'\" > \"$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP\" 2>&1"
Logger "Command output: $sqlCmd" "DEBUG" Logger "Command output: $sqlCmd" "DEBUG"
eval "$sqlCmd" & eval "$sqlCmd" &
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
Logger "Listing databases succeeded." "NOTICE" Logger "Listing databases succeeded." "NOTICE"
@ -500,7 +500,7 @@ function ListRecursiveBackupDirectories {
Logger "Listing directories to backup." "NOTICE" Logger "Listing directories to backup." "NOTICE"
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
_ListRecursiveBackupDirectoriesLocal & _ListRecursiveBackupDirectoriesLocal &
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_TOTAL $HARD_MAX_EXEC_TIME_TOTAL $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_TOTAL $HARD_MAX_EXEC_TIME_TOTAL $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
output_file="" output_file=""
else else
@ -508,7 +508,7 @@ function ListRecursiveBackupDirectories {
fi fi
elif [ "$BACKUP_TYPE" == "pull" ]; then elif [ "$BACKUP_TYPE" == "pull" ]; then
_ListRecursiveBackupDirectoriesRemote & _ListRecursiveBackupDirectoriesRemote &
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_TOTAL $HARD_MAX_EXEC_TIME_TOTAL $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_TOTAL $HARD_MAX_EXEC_TIME_TOTAL $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
output_file="" output_file=""
else else
@ -573,7 +573,7 @@ function _GetDirectoriesSizeLocal {
cmd="du -cs $dirList | tail -n1 | cut -f1 > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP 2> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" cmd="du -cs $dirList | tail -n1 | cut -f1 > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP 2> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP"
Logger "Launching command [$cmd]." "DEBUG" Logger "Launching command [$cmd]." "DEBUG"
eval "$cmd" & eval "$cmd" &
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
# $cmd will return 0 even if some errors found, so we need to check if there is an error output # $cmd will return 0 even if some errors found, so we need to check if there is an error output
retval=$? retval=$?
if [ $retval -ne 0 ] || [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then if [ $retval -ne 0 ] || [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
@ -624,7 +624,7 @@ include #### RemoteLogger SUBSET ####
exit $retval exit $retval
ENDSSH ENDSSH
# $cmd will return 0 even if some errors found, so we need to check if there is an error output # $cmd will return 0 even if some errors found, so we need to check if there is an error output
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ $retval -ne 0 ] || [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then if [ $retval -ne 0 ] || [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
Logger "Could not get files size for some or all remote directories." "ERROR" Logger "Could not get files size for some or all remote directories." "ERROR"
@ -672,7 +672,7 @@ function _CreateDirectoryLocal {
if [ ! -d "$dirToCreate" ]; then if [ ! -d "$dirToCreate" ]; then
# No sudo, you should have all necessary rights # No sudo, you should have all necessary rights
mkdir -p "$dirToCreate" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP 2>&1 & mkdir -p "$dirToCreate" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP 2>&1 &
ExecTasks "${FUNCNAME[0]}" 0 0 720 1800 $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 720 1800 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ $retval -ne 0 ]; then if [ $retval -ne 0 ]; then
Logger "Cannot create directory [$dirToCreate]" "CRITICAL" Logger "Cannot create directory [$dirToCreate]" "CRITICAL"
@ -713,7 +713,7 @@ include #### RemoteLogger SUBSET ####
fi fi
exit 0 exit 0
ENDSSH ENDSSH
ExecTasks "${FUNCNAME[0]}" 0 0 720 1800 $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 720 1800 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ $retval -ne 0 ]; then if [ $retval -ne 0 ]; then
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR" Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"
@ -778,7 +778,7 @@ function GetDiskSpaceLocal {
# Not elegant solution to make df silent on errors # Not elegant solution to make df silent on errors
# No sudo on local commands, assuming you should have all the necesarry rights to check backup directories sizes # No sudo on local commands, assuming you should have all the necesarry rights to check backup directories sizes
$DF_CMD "$pathToCheck" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1 & $DF_CMD "$pathToCheck" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1 &
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_TOTAL $HARD_MAX_EXEC_TIME_TOTAL $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_TOTAL $HARD_MAX_EXEC_TIME_TOTAL $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ $retval -ne 0 ]; then if [ $retval -ne 0 ]; then
DISK_SPACE=0 DISK_SPACE=0
@ -837,7 +837,7 @@ function _GetDiskSpaceRemoteSub {
_GetDiskSpaceRemoteSub _GetDiskSpaceRemoteSub
exit $? exit $?
ENDSSH ENDSSH
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_TOTAL $HARD_MAX_EXEC_TIME_TOTAL $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_TOTAL $HARD_MAX_EXEC_TIME_TOTAL $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ $retval -ne 0 ]; then if [ $retval -ne 0 ]; then
DISK_SPACE=0 DISK_SPACE=0
@ -1017,7 +1017,7 @@ function _BackupDatabaseLocalToLocal {
Logger "Launching command [$drySqlCmd]." "DEBUG" Logger "Launching command [$drySqlCmd]." "DEBUG"
eval "$drySqlCmd" & eval "$drySqlCmd" &
fi fi
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
if [ $_DRYRUN == false ]; then if [ $_DRYRUN == false ]; then
@ -1066,7 +1066,7 @@ function _BackupDatabaseLocalToRemote {
Logger "Launching command [$drySqlCmd]." "DEBUG" Logger "Launching command [$drySqlCmd]." "DEBUG"
eval "$drySqlCmd" & eval "$drySqlCmd" &
fi fi
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
if [ $_DRYRUN == false ]; then if [ $_DRYRUN == false ]; then
@ -1115,7 +1115,7 @@ function _BackupDatabaseRemoteToLocal {
Logger "Launching command [$drySqlCmd]." "DEBUG" Logger "Launching command [$drySqlCmd]." "DEBUG"
eval "$drySqlCmd" & eval "$drySqlCmd" &
fi fi
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" ]; then
if [ $_DRYRUN == false ]; then if [ $_DRYRUN == false ]; then
@ -1429,7 +1429,7 @@ function Rsync {
Logger "Launching command [$rsyncCmd]." "DEBUG" Logger "Launching command [$rsyncCmd]." "DEBUG"
eval "$rsyncCmd" & eval "$rsyncCmd" &
ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
retval=$? retval=$?
if [ $retval -ne 0 ]; then if [ $retval -ne 0 ]; then
Logger "Failed to backup [$sourceDir] to [$destinationDir]." "ERROR" Logger "Failed to backup [$sourceDir] to [$destinationDir]." "ERROR"
@ -1579,7 +1579,7 @@ function _RotateBackupsLocal {
cmd="rm -rf \"$path\"" cmd="rm -rf \"$path\""
Logger "Launching command [$cmd]." "DEBUG" Logger "Launching command [$cmd]." "DEBUG"
eval "$cmd" & eval "$cmd" &
ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
Logger "Cannot delete oldest copy [$path]." "ERROR" Logger "Cannot delete oldest copy [$path]." "ERROR"
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN" _LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN"
@ -1592,7 +1592,7 @@ function _RotateBackupsLocal {
cmd="mv \"$path\" \"$backup.$PROGRAM.$copy\"" cmd="mv \"$path\" \"$backup.$PROGRAM.$copy\""
Logger "Launching command [$cmd]." "DEBUG" Logger "Launching command [$cmd]." "DEBUG"
eval "$cmd" & eval "$cmd" &
ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
Logger "Cannot move [$path] to [$backup.$PROGRAM.$copy]." "ERROR" Logger "Cannot move [$path] to [$backup.$PROGRAM.$copy]." "ERROR"
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN" _LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN"
@ -1607,7 +1607,7 @@ function _RotateBackupsLocal {
cmd="mv \"$backup\" \"$backup.$PROGRAM.1\"" cmd="mv \"$backup\" \"$backup.$PROGRAM.1\""
Logger "Launching command [$cmd]." "DEBUG" Logger "Launching command [$cmd]." "DEBUG"
eval "$cmd" & eval "$cmd" &
ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
Logger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR" Logger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN" _LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN"
@ -1617,7 +1617,7 @@ function _RotateBackupsLocal {
cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\"" cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\""
Logger "Launching command [$cmd]." "DEBUG" Logger "Launching command [$cmd]." "DEBUG"
eval "$cmd" & eval "$cmd" &
ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
Logger "Cannot copy [$backup] to [$backup.$PROGRAM.1]." "ERROR" Logger "Cannot copy [$backup] to [$backup.$PROGRAM.1]." "ERROR"
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN" _LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN"
@ -1627,7 +1627,7 @@ function _RotateBackupsLocal {
cmd="mv \"$backup\" \"$backup.$PROGRAM.1\"" cmd="mv \"$backup\" \"$backup.$PROGRAM.1\""
Logger "Launching command [$cmd]." "DEBUG" Logger "Launching command [$cmd]." "DEBUG"
eval "$cmd" & eval "$cmd" &
ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 3600 0 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
Logger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR" Logger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN" _LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN"
@ -1715,7 +1715,7 @@ function _RotateBackupsRemoteSSH {
ENDSSH ENDSSH
ExecTasks "${FUNCNAME[0]}" 0 0 1800 0 $SLEEP_TIME $KEEP_LOGGING true true false false $! ExecTasks "${FUNCNAME[0]}" 0 0 1800 0 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
Logger "Could not rotate backups in [$backupPath]." "ERROR" Logger "Could not rotate backups in [$backupPath]." "ERROR"
Logger "Command output:\n $(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR" Logger "Command output:\n $(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR"