From d8fe8c9f61e76ea1fbb7d9482370f05f8bfa2e8f Mon Sep 17 00:00:00 2001 From: Haneef <298208+haneef95@users.noreply.github.com> Date: Thu, 18 Nov 2021 00:50:04 +0000 Subject: [PATCH] Specify amount of backups to keep variable --- util/MsSql/backup-db.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/MsSql/backup-db.sh b/util/MsSql/backup-db.sh index b0dbcec64..a749b4e1a 100644 --- a/util/MsSql/backup-db.sh +++ b/util/MsSql/backup-db.sh @@ -2,6 +2,7 @@ BACKUP_INTERVAL=${BACKUP_INTERVAL:-next day} BACKUP_INTERVAL_FORMAT=${BACKUP_INTERVAL_FORMAT:-%Y-%m-%d 00:00:00} export BACKUP_DB_DIR=${BACKUP_DB_DIR:-'/etc/bitwarden/mssql/backups/'} +BACKUP_DB_KEEP_MTIME=${BACKUP_DB_KEEP_MTIME:-'+32'} while true do @@ -21,7 +22,7 @@ do # Delete backup files older than 30 days grep -B1 "BACKUP DATABASE successfully" /var/opt/mssql/log/errorlog | grep -q _${BACKUP_DB_FILENAME}.BAK && - find $BACKUP_DB_DIR -mindepth 1 -type f -name '*.BAK' -mtime +32 -delete + find $BACKUP_DB_DIR -mindepth 1 -type f -name '*.BAK' -mtime $BACKUP_DB_KEEP_MTIME -delete # Common variables used in the next two if blocks. DATABASE=${DATABASE:-'vault'}