Maintenance: Closes #3570 - Make deletion of old backup more precise.

This commit is contained in:
svnr-dvnkln 2021-06-17 10:46:41 +02:00 committed by Martin Gruner
parent 64f72916cb
commit 837a9bd45c
2 changed files with 7 additions and 1 deletions

3
.gitignore vendored
View file

@ -13,6 +13,9 @@
# database (copy from config/database/database.yml, or use `rails bs:init`) # database (copy from config/database/database.yml, or use `rails bs:init`)
/config/database.yml /config/database.yml
# local backup config file
/contrib/backup/config
# Third-Party ------------------------------------------------------------------ # Third-Party ------------------------------------------------------------------
# The config files / dev tools listed below are optional # The config files / dev tools listed below are optional
# and may not be present on most users' machines # and may not be present on most users' machines

View file

@ -16,7 +16,10 @@ function get_backup_date () {
} }
function delete_old_backups () { function delete_old_backups () {
test -d ${BACKUP_DIR} && find ${BACKUP_DIR}/*_zammad_*.gz -type f -mtime +${HOLD_DAYS} -delete # Use -mmin to clean up files as -mtime (days) is too unprecise.
# However, add +60 minutes to allow for the backup script run time, so that
# backups created a few minutes more than a day ago are not already purged.
test -d ${BACKUP_DIR} && find ${BACKUP_DIR}/*_zammad_*.gz -type f -mmin +$(((60*24)*${HOLD_DAYS}+60)) -delete
} }
function get_db_credentials () { function get_db_credentials () {