Skip to content

Instantly share code, notes, and snippets.

@solusipse
Created January 9, 2016 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solusipse/9975886d1900ecb4f7b8 to your computer and use it in GitHub Desktop.
Save solusipse/9975886d1900ecb4f7b8 to your computer and use it in GitHub Desktop.
postgresql backup
#!/bin/bash
# remember to set local to trust in pg_hba.conf
sudo -u postgres pg_dumpall | gzip -c > /backup/db.sql
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "Database backup failed at domain.com!" | mail -s "Backup error" your@address.com
fi
chmod 0600 /backup/db.sql
date > /backup/last.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment