From 130e5a3aa0dc8644d4772a6e190bd5251dcf9eae Mon Sep 17 00:00:00 2001 From: PedroCapdevila <42984441+PedroCapdevila@users.noreply.github.com> Date: Tue, 5 Apr 2022 14:00:31 -0300 Subject: [PATCH] Fix delete old backups in folder last --- backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.sh b/backup.sh index 7c8586c..ebd481b 100755 --- a/backup.sh +++ b/backup.sh @@ -108,7 +108,7 @@ for DB in ${POSTGRES_DBS}; do ln -svf "${MONTHY_FILENAME}" "${BACKUP_DIR}/monthly/${DB}-latest${BACKUP_SUFFIX}" #Clean old files echo "Cleaning older files for ${DB} database from ${POSTGRES_HOST}..." - find "${BACKUP_DIR}/last" -maxdepth 1 -mmin "${KEEP_MINS}" -name "${DB}-*${BACKUP_SUFFIX}" -exec rm -rf '{}' ';' + find "${BACKUP_DIR}/last" -maxdepth 1 -mmin "+${KEEP_MINS}" -name "${DB}-*${BACKUP_SUFFIX}" -exec rm -rf '{}' ';' find "${BACKUP_DIR}/daily" -maxdepth 1 -mtime "+${KEEP_DAYS}" -name "${DB}-*${BACKUP_SUFFIX}" -exec rm -rf '{}' ';' find "${BACKUP_DIR}/weekly" -maxdepth 1 -mtime "+${KEEP_WEEKS}" -name "${DB}-*${BACKUP_SUFFIX}" -exec rm -rf '{}' ';' find "${BACKUP_DIR}/monthly" -maxdepth 1 -mtime "+${KEEP_MONTHS}" -name "${DB}-*${BACKUP_SUFFIX}" -exec rm -rf '{}' ';'