PostgreSQL Backups and Migration
database snapshot
$ pg_dump -h hostname - d dbname -U username > mysnapshot.sql
The password can be included in the command above, otherwise you'll be prompted for the password. [1]
The -a option will dump only the data in the database, not the structure. [2]
It's also possible to compress the dump:
$ pg_dump -h hostname - d dbname -U username | gzip > mysnapshot.gz $ gunzip -c mysnapshot.gz | psql dbname
Restoring a dump
$ psql dbname < mysnapshot.sql