Merge pull request #394 from tlindsay42/archive-cleanup

Add configurable archive cleanup
This commit is contained in:
Alexander Savchuk 2020-09-24 21:07:16 +12:00 committed by GitHub
commit 5b69c6a63f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -2,7 +2,7 @@
# Minecraft Server Manager Cron
#
# Backs up worlds, rolls logs, moves worlds in RAM to disk,
# and starts crashed servers
# starts crashed servers, and deletes old archives
#
# For more information visit the project home page:
# https://github.com/msmhq/msm
@ -20,3 +20,15 @@
# Start any crashed servers again each hour
@hourly minecraft /etc/init.d/msm start
# Deletes all server log files older than the number of days specified in the mtime parameter value
10 05 * * * minecraft find /opt/msm/servers/*/logs -maxdepth 1 -mtime +30 -type f -name "*.log.gz" | xargs rm --force
# Deletes all server backup files older than the number of days specified in the mtime parameter value
12 05 * * * minecraft find /opt/msm/archives/backups -maxdepth 2 -mtime +30 -type f -name "*.zip" | xargs rm --force
# Deletes all msm log files older than the number of days specified in the mtime parameter value
14 05 * * * minecraft find /opt/msm/archives/logs -maxdepth 2 -mtime +30 -type f -name "*.log.gz" | xargs rm --force
# Deletes all server world backup files older than the number of days specified in the mtime parameter value
16 05 * * * minecraft find /opt/msm/archives/worlds -maxdepth 3 -mtime +30 -type f -name "*.zip" | xargs rm --force

View File

@ -106,7 +106,8 @@ function patch_latest_files() {
# patch cron file
install_log "Patching MSM cron file"
sudo awk '{ if ($0 !~ /^#/) sub(/minecraft/, "'$msm_user'"); print }' \
"$dl_dir/msm.cron.orig" >"$dl_dir/msm.cron"
"$dl_dir/msm.cron.orig" | \
sed "s#/opt/msm#$msm_dir#g" >"$dl_dir/msm.cron"
# patch init file
install_log "Patching MSM init file"