PostgreSQL: Dump Shortcuts

Creating a Database Dump

$> pg_dump -U postgres -d db_name -W --verbose > dumb_file_name.sql

For example, if we want to create a database dump for database app_dev and save it in a app_dev_aug2017.sql file, we can do:

$> pg_dump -U postgres -d app_dev -W --verbose >app_dev_aug2017.sql

Restoring Database Dump (from pg_dump)

$> psql -U postgres db_name < /path/to/database/dump/file.sql

* Feel free to replace postgres with your database username

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s