Skip to content

Instantly share code, notes, and snippets.

@tinderfields
Created March 25, 2013 16:29
Show Gist options
  • Save tinderfields/5238440 to your computer and use it in GitHub Desktop.
Save tinderfields/5238440 to your computer and use it in GitHub Desktop.
Dump and restore a Postgres database
# Backup
pg_dump -U db_user -h localhost -xcO db_name | bzip2 - - > db/db_name.sql.bz2
# Restore
# Delete database then recreate then
bunzip2 -f db/db_name.sql.bz2
psql -U db_user -h localhost db_name < db/db_name.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment