Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nim4n136/1bcf6344943f3e7abac9caa5ddca7a98 to your computer and use it in GitHub Desktop.
Save nim4n136/1bcf6344943f3e7abac9caa5ddca7a98 to your computer and use it in GitHub Desktop.
#!/bin/bash
ARCHIVEDIR='/var/lib/pgsql/wal_archive'
LAST_BACKUP=$(ls -lto ${ARCHIVEDIR})
FILE_LIST=$(pg_archivecleanup -n "${ARCHIVEDIR}" "${LAST_BACKUP}")
## TEST FIRST
pg_archivecleanup -n "${ARCHIVEDIR}" "${LAST_BACKUP}" | find -type f -mmin +30 | xargs ls -lh
##THEN UNCOMMENT THIS LINE
##pg_archivecleanup -n "${ARCHIVEDIR}" "${LAST_BACKUP}" | find -type f -mmin +30 -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment