From 837a9bd45c783757bdbe77f305887a0f46d0b865 Mon Sep 17 00:00:00 2001 From: svnr-dvnkln <33687762+svnr-dvnkln@users.noreply.github.com> Date: Thu, 17 Jun 2021 10:46:41 +0200 Subject: [PATCH] Maintenance: Closes #3570 - Make deletion of old backup more precise. --- .gitignore | 3 +++ contrib/backup/functions | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0f2e07025..9c671a4e3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ # database (copy from config/database/database.yml, or use `rails bs:init`) /config/database.yml +# local backup config file +/contrib/backup/config + # Third-Party ------------------------------------------------------------------ # The config files / dev tools listed below are optional # and may not be present on most users' machines diff --git a/contrib/backup/functions b/contrib/backup/functions index c25823072..205be5706 100644 --- a/contrib/backup/functions +++ b/contrib/backup/functions @@ -16,7 +16,10 @@ function get_backup_date () { } 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 () {