Thursday, January 21, 2010

HOWTO Backup a Postgres database

Easy!

pg_dump -U username -h localhost dbname > backup_2010_01_22.sql

Here's a quick and dirty way to send it over the network compressed. On the postgres box:

pg_dump -U username -h localhost dbname | gzip -1 | nc -q 2 backup 5000

And on the backup box:

nc -l 5000 > pg_backup_2010_01_22.sql.gz

No comments: