PostgreSQL backup

PostgreSQL databases are dumped with the pg_dump command. A simple shell script to do the backup job could be as follows:

pg_dump -h <hostname> -U <user> -f <dumpfile> -Z 9 <dbname>

Passwords cannot be transfered to the pg_dump as a parameter, you must create a file .pgpass in the home directory of the calling user with the following content:


Leave a Reply

Your email address will not be published. Required fields are marked *

15 − 12 =

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