1
0
mirror of https://github.com/deajan/obackup.git synced 2024-12-26 15:33:41 +01:00

Rebuilt targets

This commit is contained in:
deajan 2016-08-17 10:01:55 +02:00
parent a84a8c95f9
commit 87dd096f61
3 changed files with 93 additions and 74 deletions

View File

@ -1,13 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#TODO: test bad return of _GetDirectoriesSizeLocal & Remote #TODO: test bad return of _GetDirectoriesSizeRemote
#TODO(critical): fix double path in rotate functions (switching from ls to find)
#TODO(high): check paths with spaces (again)
#TODO(low): investigate all exit codes and adapt depending on WARN / ERROR so obackup-batch won't rerun WARN runs
#TODO(low): obackup-rerun is minimal 1 and not 0
###### Remote push/pull (or local) backup script for files & databases ###### Remote push/pull (or local) backup script for files & databases
PROGRAM="obackup" PROGRAM="obackup"
AUTHOR="(C) 2013-2016 by Orsiris de Jong" AUTHOR="(C) 2013-2016 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-dev PROGRAM_VERSION=2.1-dev
PROGRAM_BUILD=2016081603 PROGRAM_BUILD=2016081702
IS_STABLE=no IS_STABLE=no
#### MINIMAL-FUNCTION-SET BEGIN #### #### MINIMAL-FUNCTION-SET BEGIN ####
@ -1344,7 +1348,7 @@ CAN_BACKUP_FILES=1
function TrapStop { function TrapStop {
Logger "/!\ Manual exit of backup script. Backups may be in inconsistent state." "WARN" Logger "/!\ Manual exit of backup script. Backups may be in inconsistent state." "WARN"
exit 1 exit 2
} }
function TrapQuit { function TrapQuit {
@ -1440,7 +1444,7 @@ function CheckCurrentConfig {
fi fi
# Check all variables that should contain a numerical value >= 0 # Check all variables that should contain a numerical value >= 0
declare -a num_vars=(BACKUP_SIZE_MINIMUM SQL_WARN_MIN_SPACE FILE_WARN_MIN_SPACE SOFT_MAX_EXEC_TIME_DB_TASK HARD_MAX_EXEC_TIME_DB_TASK COMPRESSION_LEVEL SOFT_MAX_EXEC_TIME_FILE_TASK HARD_MAX_EXEC_TIME_FILE_TASK BANDWIDTH SOFT_MAX_EXEC_TIME_TOTAL HARD_MAX_EXEC_TIME_TOTAL ROTATE_SQL_COPIES ROTATE_FILE_COPIES MAX_EXEC_TIME_PER_CMD_BEFORE MAX_EXEC_TIME_PER_CMD_AFTER) declare -a num_vars=(BACKUP_SIZE_MINIMUM SQL_WARN_MIN_SPACE FILE_WARN_MIN_SPACE SOFT_MAX_EXEC_TIME_DB_TASK HARD_MAX_EXEC_TIME_DB_TASK COMPRESSION_LEVEL SOFT_MAX_EXEC_TIME_FILE_TASK HARD_MAX_EXEC_TIME_FILE_TASK BANDWIDTH SOFT_MAX_EXEC_TIME_TOTAL HARD_MAX_EXEC_TIME_TOTAL ROTATE_SQL_COPIES ROTATE_FILE_COPIES KEEP_LOGGING MAX_EXEC_TIME_PER_CMD_BEFORE MAX_EXEC_TIME_PER_CMD_AFTER)
for i in "${num_vars[@]}"; do for i in "${num_vars[@]}"; do
test="if [ $(IsNumeric \"\$$i\") -eq 0 ]; then Logger \"Bogus $i value defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi" test="if [ $(IsNumeric \"\$$i\") -eq 0 ]; then Logger \"Bogus $i value defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
eval "$test" eval "$test"
@ -2289,22 +2293,22 @@ function _RotateBackupsLocal {
copy=$rotate_copies copy=$rotate_copies
while [ $copy -gt 1 ]; do while [ $copy -gt 1 ]; do
if [ $copy -eq $rotate_copies ]; then if [ $copy -eq $rotate_copies ]; then
cmd="rm -rf \"$backup_path/$backup.$PROGRAM.$copy\"" cmd="rm -rf \"$backup.$PROGRAM.$copy\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot delete oldest copy [$backup_path/$backup.$PROGRAM.$copy]." "ERROR" Logger "Cannot delete oldest copy [$backup.$PROGRAM.$copy]." "ERROR"
fi fi
fi fi
path="$backup_path/$backup.$PROGRAM.$(($copy-1))" path="$backup.$PROGRAM.$(($copy-1))"
if [[ -f $path || -d $path ]]; then if [[ -f $path || -d $path ]]; then
cmd="mv \"$path\" \"$backup_path/$backup.$PROGRAM.$copy\"" cmd="mv \"$path\" \"$backup.$PROGRAM.$copy\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot move [$path] to [$backup_path/$backup.$PROGRAM.$copy]." "ERROR" Logger "Cannot move [$path] to [$backup.$PROGRAM.$copy]." "ERROR"
fi fi
fi fi
@ -2313,30 +2317,30 @@ function _RotateBackupsLocal {
# Latest file backup will not be moved if script configured for remote backup so next rsync execution will only do delta copy instead of full one # Latest file backup will not be moved if script configured for remote backup so next rsync execution will only do delta copy instead of full one
if [[ $backup == *.sql.* ]]; then if [[ $backup == *.sql.* ]]; then
cmd="mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="mv \"$backup\" \"$backup.$PROGRAM.1\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot move [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" Logger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
elif [ "$REMOTE_OPERATION" == "yes" ]; then elif [ "$REMOTE_OPERATION" == "yes" ]; then
cmd="cp -R \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot copy [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" Logger "Cannot copy [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
else else
cmd="mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="mv \"$backup\" \"$backup.$PROGRAM.1\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot move [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" Logger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
fi fi
done done
@ -2393,20 +2397,20 @@ function _RotateBackupsRemoteSSH {
copy=$rotate_copies copy=$rotate_copies
while [ $copy -gt 1 ]; do while [ $copy -gt 1 ]; do
if [ $copy -eq $rotate_copies ]; then if [ $copy -eq $rotate_copies ]; then
cmd="$COMMAND_SUDO rm -rf \"$backup_path/$backup.$PROGRAM.$copy\"" cmd="$COMMAND_SUDO rm -rf \"$backup.$PROGRAM.$copy\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot delete oldest copy [$backup_path/$backup.$PROGRAM.$copy]." "ERROR" RemoteLogger "Cannot delete oldest copy [$backup.$PROGRAM.$copy]." "ERROR"
fi fi
fi fi
path="$backup_path/$backup.$PROGRAM.$(($copy-1))" path="$backup.$PROGRAM.$(($copy-1))"
if [[ -f $path || -d $path ]]; then if [[ -f $path || -d $path ]]; then
cmd="$COMMAND_SUDO mv \"$path\" \"$backup_path/$backup.$PROGRAM.$copy\"" cmd="$COMMAND_SUDO mv \"$path\" \"$backup.$PROGRAM.$copy\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot move [$path] to [$backup_path/$backup.$PROGRAM.$copy]." "ERROR" RemoteLogger "Cannot move [$path] to [$backup.$PROGRAM.$copy]." "ERROR"
fi fi
fi fi
@ -2415,27 +2419,27 @@ function _RotateBackupsRemoteSSH {
# Latest file backup will not be moved if script configured for remote backup so next rsync execution will only do delta copy instead of full one # Latest file backup will not be moved if script configured for remote backup so next rsync execution will only do delta copy instead of full one
if [[ $backup == *.sql.* ]]; then if [[ $backup == *.sql.* ]]; then
cmd="$COMMAND_SUDO mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="$COMMAND_SUDO mv \"$backup\" \"$backup.$PROGRAM.1\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot move [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" RemoteLogger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
elif [ "$REMOTE_OPERATION" == "yes" ]; then elif [ "$REMOTE_OPERATION" == "yes" ]; then
cmd="$COMMAND_SUDO cp -R \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="$COMMAND_SUDO cp -R \"$backup\" \"$backup.$PROGRAM.1\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot copy [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" RemoteLogger "Cannot copy [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
else else
cmd="$COMMAND_SUDO mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="$COMMAND_SUDO mv \"$backup\" \"$backup.$PROGRAM.1\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot move [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" RemoteLogger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
fi fi
done done

View File

@ -3,7 +3,7 @@ SUBPROGRAM=obackup
PROGRAM="$SUBPROGRAM-batch" # Batch program to run osync / obackup instances sequentially and rerun failed ones PROGRAM="$SUBPROGRAM-batch" # Batch program to run osync / obackup instances sequentially and rerun failed ones
AUTHOR="(L) 2013-2016 by Orsiris de Jong" AUTHOR="(L) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr - ozy@netpower.fr" CONTACT="http://www.netpower.fr - ozy@netpower.fr"
PROGRAM_BUILD=2016052501 PROGRAM_BUILD=2016081701
## Runs an osync /obackup instance for every conf file found ## Runs an osync /obackup instance for every conf file found
## If an instance fails, run it again if time permits ## If an instance fails, run it again if time permits
@ -14,8 +14,8 @@ CONF_FILE_PATH=/etc/$SUBPROGRAM
## If maximum execution time is not reached, failed instances will be rerun. Max exec time is in seconds. Example is set to 10 hours. ## If maximum execution time is not reached, failed instances will be rerun. Max exec time is in seconds. Example is set to 10 hours.
MAX_EXECUTION_TIME=36000 MAX_EXECUTION_TIME=36000
## Specifies the number of reruns an instance may get ## Specifies the number of total runs an instance may get
MAX_RERUNS=3 MAX_RUNS=3
## Log file path ## Log file path
if [ -w /var/log ]; then if [ -w /var/log ]; then
@ -78,38 +78,49 @@ function CheckEnvironment {
} }
function Batch { function Batch {
local runs=0 # Number of batch runs
local runList # Actual conf file list to run
local runAgainList # List of failed conf files sto run again
local confFile
local result
## Get list of .conf files ## Get list of .conf files
for i in $CONF_FILE_PATH/*.conf for confFile in "$CONF_FILE_PATH/*.conf"
do do
if [ "$RUN" == "" ]; then if [ "$runList" == "" ]; then
RUN="$i" runList="$confFile"
else else
RUN=$RUN" $i" runList=$runList" $confFile"
fi fi
done done
RERUNS=0 while ([ $MAX_EXECUTION_TIME -gt $SECONDS ] || [ $MAX_EXECUTION_TIME -eq 0 ]) && [ "$runList" != "" ] && [ $MAX_RUNS -gt $runs ]
while ([ $MAX_EXECUTION_TIME -gt $SECONDS ] || [ $MAX_EXECUTION_TIME -eq 0 ]) && [ "$RUN" != "" ] && [ $MAX_RERUNS -gt $RERUNS ]
do do
Logger "$SUBPROGRAM instances will be run for: $RUN" "NOTICE" Logger "$SUBPROGRAM instances will be run for: $runList" "NOTICE"
for i in $RUN for confFile in $runList
do do
$SUBPROGRAM_EXECUTABLE "$i" $opts & $SUBPROGRAM_EXECUTABLE "$confFile" $opts &
wait $! wait $!
if [ $? != 0 ]; then result=$?
Logger "Run instance $(basename $i) failed" "ERROR" if [ $result != 0 ]; then
if [ "$RUN_AGAIN" == "" ]; then if [ $result == 1 ] || [ $result == 120 ] || [ $result == 128 ]; then
RUN_AGAIN="$i" Logger "Run instance $(basename $confFile) failed with exit code [$result]." "ERROR"
else if [ "$runAgainList" == "" ]; then
RUN_AGAIN=$RUN_AGAIN" $i" runAgainList="$confFile"
else
runAgainList=$runAgainList" $confFile"
fi
elif [ $result == 2 ]; then
Logger "Run instance $(basename $confFile) finished with warnings." "WARN"
fi fi
else else
Logger "Run instance $(basename $i) succeed." "NOTICE" Logger "Run instance $(basename $confFile) succeed." "NOTICE"
fi fi
done done
RUN="$RUN_AGAIN" runList="$runAgainList"
RUN_AGAIN="" runAgainList=""
RERUNS=$(($RERUNS + 1)) runs=$(($runs + 1))
done done
} }

View File

@ -1,13 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#TODO: test bad return of _GetDirectoriesSizeLocal & Remote #TODO: test bad return of _GetDirectoriesSizeRemote
#TODO(critical): fix double path in rotate functions (switching from ls to find)
#TODO(high): check paths with spaces (again)
#TODO(low): investigate all exit codes and adapt depending on WARN / ERROR so obackup-batch won't rerun WARN runs
#TODO(low): obackup-rerun is minimal 1 and not 0
###### Remote push/pull (or local) backup script for files & databases ###### Remote push/pull (or local) backup script for files & databases
PROGRAM="obackup" PROGRAM="obackup"
AUTHOR="(C) 2013-2016 by Orsiris de Jong" AUTHOR="(C) 2013-2016 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-dev PROGRAM_VERSION=2.1-dev
PROGRAM_BUILD=2016081603 PROGRAM_BUILD=2016081702
IS_STABLE=no IS_STABLE=no
#### MINIMAL-FUNCTION-SET BEGIN #### #### MINIMAL-FUNCTION-SET BEGIN ####
@ -1270,7 +1274,7 @@ CAN_BACKUP_FILES=1
function TrapStop { function TrapStop {
Logger "/!\ Manual exit of backup script. Backups may be in inconsistent state." "WARN" Logger "/!\ Manual exit of backup script. Backups may be in inconsistent state." "WARN"
exit 1 exit 2
} }
function TrapQuit { function TrapQuit {
@ -1364,7 +1368,7 @@ function CheckCurrentConfig {
fi fi
# Check all variables that should contain a numerical value >= 0 # Check all variables that should contain a numerical value >= 0
declare -a num_vars=(BACKUP_SIZE_MINIMUM SQL_WARN_MIN_SPACE FILE_WARN_MIN_SPACE SOFT_MAX_EXEC_TIME_DB_TASK HARD_MAX_EXEC_TIME_DB_TASK COMPRESSION_LEVEL SOFT_MAX_EXEC_TIME_FILE_TASK HARD_MAX_EXEC_TIME_FILE_TASK BANDWIDTH SOFT_MAX_EXEC_TIME_TOTAL HARD_MAX_EXEC_TIME_TOTAL ROTATE_SQL_COPIES ROTATE_FILE_COPIES MAX_EXEC_TIME_PER_CMD_BEFORE MAX_EXEC_TIME_PER_CMD_AFTER) declare -a num_vars=(BACKUP_SIZE_MINIMUM SQL_WARN_MIN_SPACE FILE_WARN_MIN_SPACE SOFT_MAX_EXEC_TIME_DB_TASK HARD_MAX_EXEC_TIME_DB_TASK COMPRESSION_LEVEL SOFT_MAX_EXEC_TIME_FILE_TASK HARD_MAX_EXEC_TIME_FILE_TASK BANDWIDTH SOFT_MAX_EXEC_TIME_TOTAL HARD_MAX_EXEC_TIME_TOTAL ROTATE_SQL_COPIES ROTATE_FILE_COPIES KEEP_LOGGING MAX_EXEC_TIME_PER_CMD_BEFORE MAX_EXEC_TIME_PER_CMD_AFTER)
for i in "${num_vars[@]}"; do for i in "${num_vars[@]}"; do
test="if [ $(IsNumeric \"\$$i\") -eq 0 ]; then Logger \"Bogus $i value defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi" test="if [ $(IsNumeric \"\$$i\") -eq 0 ]; then Logger \"Bogus $i value defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
eval "$test" eval "$test"
@ -2187,22 +2191,22 @@ function _RotateBackupsLocal {
copy=$rotate_copies copy=$rotate_copies
while [ $copy -gt 1 ]; do while [ $copy -gt 1 ]; do
if [ $copy -eq $rotate_copies ]; then if [ $copy -eq $rotate_copies ]; then
cmd="rm -rf \"$backup_path/$backup.$PROGRAM.$copy\"" cmd="rm -rf \"$backup.$PROGRAM.$copy\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot delete oldest copy [$backup_path/$backup.$PROGRAM.$copy]." "ERROR" Logger "Cannot delete oldest copy [$backup.$PROGRAM.$copy]." "ERROR"
fi fi
fi fi
path="$backup_path/$backup.$PROGRAM.$(($copy-1))" path="$backup.$PROGRAM.$(($copy-1))"
if [[ -f $path || -d $path ]]; then if [[ -f $path || -d $path ]]; then
cmd="mv \"$path\" \"$backup_path/$backup.$PROGRAM.$copy\"" cmd="mv \"$path\" \"$backup.$PROGRAM.$copy\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot move [$path] to [$backup_path/$backup.$PROGRAM.$copy]." "ERROR" Logger "Cannot move [$path] to [$backup.$PROGRAM.$copy]." "ERROR"
fi fi
fi fi
@ -2211,30 +2215,30 @@ function _RotateBackupsLocal {
# Latest file backup will not be moved if script configured for remote backup so next rsync execution will only do delta copy instead of full one # Latest file backup will not be moved if script configured for remote backup so next rsync execution will only do delta copy instead of full one
if [[ $backup == *.sql.* ]]; then if [[ $backup == *.sql.* ]]; then
cmd="mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="mv \"$backup\" \"$backup.$PROGRAM.1\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot move [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" Logger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
elif [ "$REMOTE_OPERATION" == "yes" ]; then elif [ "$REMOTE_OPERATION" == "yes" ]; then
cmd="cp -R \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot copy [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" Logger "Cannot copy [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
else else
cmd="mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="mv \"$backup\" \"$backup.$PROGRAM.1\""
Logger "cmd: $cmd" "DEBUG" Logger "cmd: $cmd" "DEBUG"
eval "$cmd" & eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot move [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" Logger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
fi fi
done done
@ -2285,20 +2289,20 @@ function _RotateBackupsRemoteSSH {
copy=$rotate_copies copy=$rotate_copies
while [ $copy -gt 1 ]; do while [ $copy -gt 1 ]; do
if [ $copy -eq $rotate_copies ]; then if [ $copy -eq $rotate_copies ]; then
cmd="$COMMAND_SUDO rm -rf \"$backup_path/$backup.$PROGRAM.$copy\"" cmd="$COMMAND_SUDO rm -rf \"$backup.$PROGRAM.$copy\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot delete oldest copy [$backup_path/$backup.$PROGRAM.$copy]." "ERROR" RemoteLogger "Cannot delete oldest copy [$backup.$PROGRAM.$copy]." "ERROR"
fi fi
fi fi
path="$backup_path/$backup.$PROGRAM.$(($copy-1))" path="$backup.$PROGRAM.$(($copy-1))"
if [[ -f $path || -d $path ]]; then if [[ -f $path || -d $path ]]; then
cmd="$COMMAND_SUDO mv \"$path\" \"$backup_path/$backup.$PROGRAM.$copy\"" cmd="$COMMAND_SUDO mv \"$path\" \"$backup.$PROGRAM.$copy\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot move [$path] to [$backup_path/$backup.$PROGRAM.$copy]." "ERROR" RemoteLogger "Cannot move [$path] to [$backup.$PROGRAM.$copy]." "ERROR"
fi fi
fi fi
@ -2307,27 +2311,27 @@ function _RotateBackupsRemoteSSH {
# Latest file backup will not be moved if script configured for remote backup so next rsync execution will only do delta copy instead of full one # Latest file backup will not be moved if script configured for remote backup so next rsync execution will only do delta copy instead of full one
if [[ $backup == *.sql.* ]]; then if [[ $backup == *.sql.* ]]; then
cmd="$COMMAND_SUDO mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="$COMMAND_SUDO mv \"$backup\" \"$backup.$PROGRAM.1\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot move [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" RemoteLogger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
elif [ "$REMOTE_OPERATION" == "yes" ]; then elif [ "$REMOTE_OPERATION" == "yes" ]; then
cmd="$COMMAND_SUDO cp -R \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="$COMMAND_SUDO cp -R \"$backup\" \"$backup.$PROGRAM.1\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot copy [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" RemoteLogger "Cannot copy [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
else else
cmd="$COMMAND_SUDO mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\"" cmd="$COMMAND_SUDO mv \"$backup\" \"$backup.$PROGRAM.1\""
RemoteLogger "cmd: $cmd" "DEBUG" RemoteLogger "cmd: $cmd" "DEBUG"
eval "$cmd" eval "$cmd"
if [ $? != 0 ]; then if [ $? != 0 ]; then
RemoteLogger "Cannot move [$backup_path/$backup] to [$backup_path/$backup.$PROGRAM.1]." "ERROR" RemoteLogger "Cannot move [$backup] to [$backup.$PROGRAM.1]." "ERROR"
fi fi
fi fi
done done