From 566a518f100e5b51a74c0631553cdfa5ca1557a0 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 29 Nov 2015 06:02:15 +1000 Subject: [PATCH 1/2] 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 From b89d6e3163dd9fe669f4fe88649830ab0cfcd3df Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Mon, 30 Nov 2015 07:09:58 +1000 Subject: [PATCH 2/2] Add note on typical size of compressed backup --- tools/arkmanager.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/arkmanager.cfg b/tools/arkmanager.cfg index 245d3f5..7b75a68 100644 --- a/tools/arkmanager.cfg +++ b/tools/arkmanager.cfg @@ -17,9 +17,12 @@ 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 +#arkStagingDir="/home/steam/ARK-Staging" # Uncomment to enable updates to be fully downloaded before restarting the server (reduces downtime while updating) + +# Options to automatically remove old backups to keep backup size in check +# Each compressed backup is generally about 1-2MB in size. 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 # Modify as desired, putting the %d replacement operator where the number belongs