Export database

The shortcut command to export the DB from the console

With Schema and Data

pg_dump db_name > backup.sql

With Data Only

pg_dump -a db_name > backup.sql

With Table Only

pg_dump -d db_name -t locations_table > locations.sql

Restoring the dump

Create the database first if it does not exist. You need to make sure the database exists.

pg_dump db_name < backup.sql

Learn more

pg_dump --help