Implement old backup removal by limiting backup size

This commit is contained in:
Ben Peddell 2015-11-29 06:02:15 +10:00
parent 3d7f975037
commit 566a518f10
2 changed files with 18 additions and 1 deletions

View File

@ -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
}

View File

@ -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