From 566a518f100e5b51a74c0631553cdfa5ca1557a0 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 29 Nov 2015 06:02:15 +1000 Subject: [PATCH] Implement old backup removal by limiting backup size --- tools/arkmanager | 16 ++++++++++++++++ tools/arkmanager.cfg | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/arkmanager b/tools/arkmanager index 294cd6a..e6263fc 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -1427,6 +1427,22 @@ doBackup(){ echo -e "${NORMAL}\e[68G[ ${RED}FAILED${NORMAL} ]" fi echo -e "${NORMAL} Created Backup: ${GREEN} ${datestamp}.tar.bz2${NORMAL}" + + if [ -n "$arkMaxBackupSizeGB" ] && (( arkMaxBackupSizeGB >= 1 )); then + (( arkMaxBackupSizeMB = arkMaxBackupSizeGB * 1024 )) + fi + + if [ -n "$arkMaxBackupSizeMB" ] && (( arkMaxBackupSizeMB > 64 )); then + find "${arkbackupdir}" -type f -printf "%T@\t%s\t%p\n" | + sort -n -r | + cut -f2-3 | + (sz=0; while read fsz f; do + if (( sz / 1048576 > arkMaxBackupSizeMB )); then + rm "$f" + fi + (( sz += fsz )) + done) + fi } diff --git a/tools/arkmanager.cfg b/tools/arkmanager.cfg index 96c8c05..245d3f5 100644 --- a/tools/arkmanager.cfg +++ b/tools/arkmanager.cfg @@ -17,7 +17,8 @@ arkbackupdir="/home/steam/ARK-Backups" # path to ba arkwarnminutes="60" # number of minutes to warn players when using update --warn arkautorestartfile="ShooterGame/Saved/.autorestart" # path to autorestart file arkBackupPreUpdate="false" # set this to true if you want to perform a backup before updating -arkTimeToKeepBackupFiles="10" #Set to Automatically Remove backups older than n days +arkMaxBackupSizeMB="500" # Set to automatically remove old backups when size exceeds this limit +#arkMaxBackupSizeGB="2" # Uncomment this and comment the above to specify the limit in whole GB #arkStagingDir="/home/steam/ARK-Staging" # Uncomment to enable updates to be fully downloaded before restarting the server (reduces downtime while updating) # Update warning messages