pg_dump-restore.md
16 Jan 2017 | sqlUsing pg_dump and pg_restore to save and reload a PostgreSQL database
Test settings:
- origin DB: PostgreSQL 9.5.5, saving
rcwdtook ~5-10 min for an output file of 1.6G - destination DB: PostgreSQL 9.4.8, restoring
rcwdtook ~5-10 min for an output file of 1.6G
Saving the database
pg_dump -F tar -f $SAVE_FILE $DB_NAME
$SAVE_FILEfile to store the output$DB_NAMEdb to save-F tarto save in a tar file
Restoring the database
pg_restore $SAVE_FILE -d $DB_NAME --clean
$SAVE_FILEfile to store the output (file format is inferred from the extension--cleanerases the database $DB_NAME before restoring the data (fresh start)
Useful links
- pg_dump http://docs.postgresql.fr/9.2/app-pgdump.html
- pg_restore http://docs.postgresql.fr/8.1/app-pgrestore.html
Comments