How to Dump, backup or restore PostgreSQL Database

Valic —  December 30, 2012 — Leave a comment

Dump a PostgreSQL database:

[email protected]:~$ pg_dump db_name -v --format=c --file=./db_name.dump

Import the dump to a new PostgreSQL database:

[email protected]:~$ createdb -E UTF8 -T template0 db_new
[email protected]:~$ pg_restore -U user -d db_new ./db_name.dump
[email protected]:~$ psql --command "ALTER DATABASE db_new OWNER TO user;"

Valic

Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

No Comments

Be the first to start the conversation.

Leave a Reply