Skip to content

Instantly share code, notes, and snippets.

@sebastianwebber
Created August 5, 2016 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sebastianwebber/855585ef3ef6a50c50cca7b57bc8d7d3 to your computer and use it in GitHub Desktop.
Save sebastianwebber/855585ef3ef6a50c50cca7b57bc8d7d3 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