Commands.app

pg_dump

Backup & Restore

Backup a PostgreSQL database

Options & Flags
Available options for this command
-F

Output format (p=plain, c=custom, d=directory, t=tar)

-f

Output file or directory name

--schema-only

Dump only schema, no data

--data-only

Dump only data, no schema

-t

Dump specific table only

-j

Number of parallel jobs for dump

Examples
Common usage examples

Dump database to SQL file

pg_dump mydb > backup.sql

Create custom format backup

pg_dump -Fc mydb > backup.dump

Dump only users table

pg_dump -t users mydb > users.sql

Dump schema without data

pg_dump --schema-only mydb > schema.sql
Notes
  • Custom format (-Fc) allows selective restore
  • Use pg_dumpall to backup all databases
Related Commands
You might also find these useful