How to Dump, backup or restore PostgreSQL Database

Valic —  December 30, 2012 — Leave a comment

Dump a PostgreSQL database:

postgres@server:~$ pg_dump db_name -v --format=c --file=./db_name.dump

Import the dump to a new PostgreSQL database:

postgres@server:~$ createdb -E UTF8 -T template0 db_new
postgres@server:~$ pg_restore -U user -d db_new ./db_name.dump
postgres@server:~$ 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.