Merge pull request #303 from klightspeed/1.5-dev#limitbackupsize

Implement old backup removal by limiting backup size
This commit is contained in:
Fez Vrasta 2015-12-15 16:55:09 +01:00
commit e688c69719
2 changed files with 21 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

@ -16,9 +16,13 @@ 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
#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
# Update warning messages
# Modify as desired, putting the %d replacement operator where the number belongs
msgWarnUpdateMinutes="This ARK server will shutdown for an update in %d minutes"