1
0
mirror of https://github.com/deajan/obackup.git synced 2024-11-12 19:03:42 +01:00

Fixed double backup path in rotate functions

This commit is contained in:
deajan 2016-08-17 09:20:52 +02:00
parent 01ddddcb49
commit a74e83185a

View File

@ -979,22 +979,22 @@ function _RotateBackupsLocal {
copy=$rotate_copies
while [ $copy -gt 1 ]; do
if [ $copy -eq $rotate_copies ]; then
cmd="rm -rf \"$backup_path/$backup.$PROGRAM.$copy\""
cmd="rm -rf \"$backup.$PROGRAM.$copy\""
Logger "cmd: $cmd" "DEBUG"
eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
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
path="$backup_path/$backup.$PROGRAM.$(($copy-1))"
path="$backup.$PROGRAM.$(($copy-1))"
if [[ -f $path || -d $path ]]; then
cmd="mv \"$path\" \"$backup_path/$backup.$PROGRAM.$copy\""
cmd="mv \"$path\" \"$backup.$PROGRAM.$copy\""
Logger "cmd: $cmd" "DEBUG"
eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
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
@ -1003,30 +1003,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
if [[ $backup == *.sql.* ]]; then
cmd="mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\""
cmd="mv \"$backup\" \"$backup.$PROGRAM.1\""
Logger "cmd: $cmd" "DEBUG"
eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
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
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"
eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
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
else
cmd="mv \"$backup_path/$backup\" \"$backup_path/$backup.$PROGRAM.1\""
cmd="mv \"$backup\" \"$backup.$PROGRAM.1\""
Logger "cmd: $cmd" "DEBUG"
eval "$cmd" &
WaitForTaskCompletion $! 3600 0 ${FUNCNAME[0]} false true $KEEP_LOGGING
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
done
@ -1083,20 +1083,20 @@ function _RotateBackupsRemoteSSH {
copy=$rotate_copies
while [ $copy -gt 1 ]; do
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"
eval "$cmd"
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
path="$backup_path/$backup.$PROGRAM.$(($copy-1))"
path="$backup.$PROGRAM.$(($copy-1))"
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"
eval "$cmd"
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
@ -1105,27 +1105,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
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"
eval "$cmd"
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
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"
eval "$cmd"
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
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"
eval "$cmd"
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
done