Split backup cleanup into new function

This commit is contained in:
Jason Wood 2023-03-14 19:04:49 -05:00
parent 336fb8386f
commit 4f473206fd
No known key found for this signature in database
GPG Key ID: A1946B71FB2255C1

12
msctl
View File

@ -1648,6 +1648,16 @@ worldBackup() {
# Return a false value (failure). # Return a false value (failure).
return 1 return 1
fi fi
# Return a true value (success).
return 0
}
# ---------------------------------------------------------------------------
# Cleanup old backups for the world server.
#
# @param 1 The world server of interest.
# ---------------------------------------------------------------------------
worldBackupCleanup() {
# Cleanup old backups. # Cleanup old backups.
if [ $BACKUP_DURATION -gt 0 ]; then if [ $BACKUP_DURATION -gt 0 ]; then
if ! $RDIFF_BACKUP --remove-older-than ${BACKUP_DURATION}D --force "$BACKUP_LOCATION/$1" >>"$BACKUP_LOG"; then if ! $RDIFF_BACKUP --remove-older-than ${BACKUP_DURATION}D --force "$BACKUP_LOCATION/$1" >>"$BACKUP_LOG"; then
@ -3271,6 +3281,8 @@ case "$COMMAND" in
fi fi
# Remove the lock file. # Remove the lock file.
removeLockFile $WORLD "backup" removeLockFile $WORLD "backup"
# Cleanup old backup files.
worldBackupCleanup $WORLD
else else
printf "\nError lock file for world $WORLD could not be created." printf "\nError lock file for world $WORLD could not be created."
printf " Is the world already running a backup?\n" printf " Is the world already running a backup?\n"