diff --git a/postgresql/files/postgresql-backup.sh b/postgresql/files/postgresql-backup.sh index d4909922..64d20820 100755 --- a/postgresql/files/postgresql-backup.sh +++ b/postgresql/files/postgresql-backup.sh @@ -41,7 +41,11 @@ create_backup_dirs() { cleanup_old_backups() { # Remove the old backups - find ${HISTDIR} -ctime +$N_DAYS_TO_SPARE -exec rm -f {} \; + TODELETE=`ls /var/lib/pgsql/backups/history | awk -F '.' '{print $NF}' | sort -ruV | tail -n +${N_DAYS_TO_SPARE}` + for i in ${TODELETE} + do + rm -f /var/lib/pgsql/backups/history/*.$i + done } create_db_list() {