Skip to content

Instantly share code, notes, and snippets.

@jamesattard
Created March 20, 2017 13:53
Show Gist options
  • Select an option

  • Save jamesattard/54510d6bdbe96ccf2d6ee33b9887ebe9 to your computer and use it in GitHub Desktop.

Select an option

Save jamesattard/54510d6bdbe96ccf2d6ee33b9887ebe9 to your computer and use it in GitHub Desktop.
# Backup database Globals
su - postgres -c "pg_dumpall -g --file=/tmp/globals.sql;"
# Backup all databases
su - postgres -c 'psql -At -c "SELECT datname FROM pg_database WHERE NOT datistemplate"' | \
while read f;
do su - postgres -c "pg_dump --format=c --file=/tmp/$f.sqlc $f";
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment