← All notes

Backing up PostgreSQL with pg_dump

Answer: Use the custom (-Fc) or directory (-Fd) format and restore with pg_restore, which can run in parallel. Use pg_dumpall --globals-only for roles and tablespaces, which pg_dump does not include.

pg_dump -Fc -d shop -f shop.dump
pg_dumpall --globals-only > globals.sql

createdb shop_restored
pg_restore -j 4 -d shop_restored shop.dump

Formats

| Format | Restore with | |---|---| | plain SQL (default) | psql | | custom -Fc | pg_restore | | directory -Fd | pg_restore, parallel dump with -j | | tar -Ft | pg_restore |

Useful options

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 25.1. SQL Dump, PostgreSQL License; PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: pg_dump, PostgreSQL License.

Cite this

Permanent ID: iil:note:13e838r3

iinventedlight. 2026. "Backing up PostgreSQL with pg_dump." iinventedlight Library, iil:note:13e838r3, version of 2026-11-04. https://iinventedlight.com/library/notes/postgres-pg-dump/. License: CC-BY-4.0.

@misc{iil_note_13e838r3,
  author = {{iinventedlight}},
  title = {{Backing up PostgreSQL with pg\_dump}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/postgres-pg-dump/},
  note = {Permanent ID iil:note:13e838r3. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/postgres-pg-dump.md.