Skip to content

Instantly share code, notes, and snippets.

@vladimir-e
Last active August 29, 2015 14:26
Show Gist options
  • Save vladimir-e/07f9d6c136fff9a69955 to your computer and use it in GitHub Desktop.
Save vladimir-e/07f9d6c136fff9a69955 to your computer and use it in GitHub Desktop.
Backup and Restore PostgreSQL Database Using pg_dump and psql
# http://www.thegeekstuff.com/2009/01/how-to-backup-and-restore-postgres-database-using-pg_dump-and-psql/
# Backup:
$ pg_dump -U {user-name} {source_db} -f {dumpfilename.sql} -W
# requires to configure md5 auth:
sudo vim /etc/postgresql/9.4/main/pg_hba.conf
# add:
# local all apps md5
# Restore:
# Peer auth
sudo -u postgres psql -d tagfund_productions -f tag_development.sql
# Password auth
psql -U {user-name} -d {desintation_db}-f {dumpfilename.sql}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment