Sunday, August 5, 2018

Postgres backup and restore

Backup commands
- pg_dump db_name > db_backup.sql
- pg_dumpall > cluster_backup.sql

Restore commands
- psql db_name < db_backup.sql
- psql -f cluster_backup.sql postgres


Using compression
- pg_dump db_name | gzip > db_backup.gz
- pg_dumpall | gzip > cluster_backup.gz

Restore
- gunzip -c db_backup.gz | psql db_name
- gunzip -c cluster_backup.gz | psql postgres




reference:
https://www.rubytreesoftware.com/resources/basic-postgresql-backup-and-restore/

No comments:

Post a Comment

free online comma separating tool

https://delim.co/#