Export database
postgres, console, db – Aug 26 2018
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