Exporting/dumping your database
To export your database you need to perform a database dump. This can be done via the command line using SSH or alternately via a web based interface from the control panel.
Exporting from the control panel
PhpPgAdmin is installed and configured within the control panel for your web hosting account and provides a graphical interface which allows you to export your database.
To export your database, from the control panel:
- Click the 'PostgreSQL web interface' link
Enter the PostgreSQL username \& password
- Choose the database from the left hand navigation menu
Under 'View dump..' choose 'Structure and data' \& 'send' options, then select the Go link to the right.
- The contents of your database will download in your browser.
A PostgreSQL database export (or dump) is a plain text file that contains all of the commands required to rebuild your database. It can be viewed and modified in a text editor.
Exporting from the command line
The pg_dump command allows you to dump data from the PostgreSQL database.
To dump an entire database with schema run:
pg_dump -u database_name > dump_file.txt
Then type your username hit return, then type your password and hit return.
Where:
database_name should be replaced with your username
dump_file.txt is the filename to write the contents of the dump to.
To dump a single table with schema run:
pg_dump -u -t table_name database_name > dump_file.txt
Then type your username hit return, then type your password and hit return (note that you will not see a prompt for either the username or password).
table_name and database_name should be replaced with table and database names respectively.
Where:
database_name should be replaced with your username
table_name should be replaced with your username
dump_file.txt is the filename to write the contents of the dump to.
For more detailed information type pg_dump --help in shell or check out the documentation for pg_dump
