diff --git a/templates/postgresql-backup.sh.j2 b/templates/postgresql-backup.sh.j2 index 277c575..a1c8e3e 100755 --- a/templates/postgresql-backup.sh.j2 +++ b/templates/postgresql-backup.sh.j2 @@ -49,9 +49,9 @@ cleanup_old_backups() { # find ${HISTDIR} -mtime +${N_DAYS_TO_SPARE} -type f -exec rm -fv {} \; ORD_DUMP_TO_DEL=$( expr $N_DAYS_TO_SPARE + 1 ) TODELETE=$( /bin/ls "${HISTDIR}/" | awk -F '.' '{print $NF}' | sort -ruV | tail -n +${ORD_DUMP_TO_DEL} ) - for DATETODELETE in ${TODELETE} + for i in ${TODELETE} do - rm -fv "${DATETODELETE}/*.${i}" + rm -f "${HISTDIR}/*.${i}" done }