Use pg_dumpall to backup all databases

$ pg\_dumpall -U postgres > all.sql

Use pg_dump to backup a database

$ pg\_dump -d mydb -f mydb\_backup.sql
  •   -a   Dump only the data, not the schema
  •   -s   Dump only the schema, no data
  •   -c   Drop database before recreating
  •   -C   Create database before restoring
  •   -t   Dump the named table(s) only
  •   -F   Format (c: custom, d: directory, t: tar) Use pg_dump -? to get the full list of options
Comments