Dumping Postgres Database

Posted by yhuang
Public (Editable by Users)
Shell
None
Edit
# Dump to sql file.
pg_dump -h host -U user dbname > dump.sql

# Dump using postgres compressed mode.
pg_dump -h host -U user -Fc dbname > dump.custom

# Dump to sql file compressed with gzip.
pg_dump -h host -U user dbname | gzip > dump.sql.gz

# Dump remote database through ssh.
ssh user@host -i sshkey "pg_dump -h dbhost -U dbuser dbname" > dump.sql