Practical guide

PostgreSQL backup best practices: what the official documentation says to do

Last materially reviewed 2026-10-03

Quick answerBack up roles as well as data, keep a copy off the server, make archive_command refuse overwrites and return honest exit codes, monitor archiving, and run real test restores on a schedule.

Eight PostgreSQL backup best practices from the official documentation

The PostgreSQL backup best practices drawn from the official documentation are these: pick the method that matches how much data you can lose, back up roles and configuration as well as tables, store a copy away from the server, archive WAL with a command that never overwrites, monitor the archive, verify backups, restore them on a schedule, and write the procedure down. The table ties eight specific practices to a statement in the official documentation.

Postgres backup and restore best practices and their source
PracticeWhy the documentation says it matters
Match method to loss toleranceA dump restores only to when it began; WAL archiving allows recovery to any time since the base backup
Dump globals separatelypg_dump does not save roles or tablespaces
Keep config files in a file backupWAL archiving does not restore changes to postgresql.conf, pg_hba.conf or pg_ident.conf
Never overwrite archived WALThe archive command should refuse to overwrite an existing file
Return zero only on successPostgreSQL removes or recycles a segment once the command reports success
Monitor archivingIf it falls behind, pg_wal fills and more data is at risk
Verify, then still restorepg_verifybackup cannot run every check a live server performs
Restore into template0Guarantees an empty target without local additions

We may earn a commission if you buy through links on this page, at no extra cost to you.

See current SimpleBackups plans →

How to apply them to logical backups

  1. Use the custom or directory format. pg_dump -Fc is compressed by default and allows selective restore. See Postgres dump formats.
  2. Save roles on every run. pg_dumpall --globals-only > globals.sql
  3. Run a pg_dump at least as new as the server. It refuses servers newer than its own major version, and its output is meant to load into newer versions, not older ones.
  4. Restore safely. Create the target with createdb -T template0 newdb, use pg_restore --exit-on-error or --single-transaction so a failure is not silent, and run ANALYZE afterward.

How to apply them to physical backups and WAL archiving

  1. Set up and test archiving before the first base backup. The manual gives that order. Archiving needs wal_level at replica or higher, archive_mode = on and an archive_command.
  2. Use a command with an overwrite guard. The documented Unix example is archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'. The manual warns against relying on cp -i, because GNU cp returns zero when the file already exists.
  3. Protect the archive. It contains effectively everything in the database, so restrict who can read it.
  4. Bound the delay. Only completed segments are archived. archive_timeout forces a switch on quiet servers; the manual calls very short values unwise because every forced segment is still full length.
  5. Take base backups with pg_basebackup and keep the manifest. The manifest is what pg_verifybackup checks against.
  6. Choose the base backup interval deliberately. Longer gaps mean more WAL to store and more to replay during recovery.

A worked example with real settings

A self-hosted 80 GB production database that can lose at most a minute or two of data might use: wal_level = replica, archive_mode = on, the guarded archive_command above pointed at a mounted archive volume, and archive_timeout set to about a minute, which the manual describes as usually reasonable. A weekly pg_basebackup -D backup -Ft -z -P writes compressed tar files with a progress report, the form shown in the reference page.

Alongside it, a nightly pg_dump -Fc gives a portable copy that survives a major version upgrade, which the physical backup does not. Both copies are sent off the server. That follows the 3-2-1 rule described in the US-CERT paper Data Backup Options: 3 copies, 2 media types, 1 off-site. Decide the loss figure first using recovery objectives, and set how long to keep each copy with a retention horizon.

Common mistakes that the documentation warns about

  • Copying the data directory of a running server. A plain file-system copy is only usable if the server was shut down, unless you use a consistent snapshot or a base backup.
  • Trying to recover to a time during the base backup. The stop point must be after the backup ended.
  • Breaking an incremental chain. PostgreSQL does not track which earlier backups an incremental needs.
  • Trusting verification alone. The pg_verifybackup page itself says to still perform test restores and check the data.
  • A restore_command that returns zero for a missing file. It must return non-zero when asked for a file that is not in the archive.

When a paid tool is worth it

Every practice above can be met with tools that ship with PostgreSQL. What native tools do not give you is someone watching. If backups have failed quietly before, or several people need to see backup status and fetch backup files without shell access to the database server, a managed service is worth paying for. SimpleBackups lists failure notifications, anomaly detection on paid plans and backup files you download for manual restore, from $0 for one job to $49 per month for five, as read on its pricing page on 3 October 2026. For WAL-level recovery, pair it with pgBackRest or your provider's point-in-time feature rather than replacing them. A written restore runbook matters in both cases.

Sources used for this page

The facts above come from the pages below, read on 3 October 2026. We have not used these products hands-on. Prices and terms change, so confirm them on the vendor's site before you buy.

  1. PostgreSQL Documentation: 25.1. SQL Dump — Vendor documentation · postgresql.org · checked 2026-10-03
  2. PostgreSQL Documentation: pg_dump — Vendor documentation · postgresql.org · checked 2026-10-03
  3. PostgreSQL Documentation: pg_restore — Vendor documentation · postgresql.org · checked 2026-10-03
  4. PostgreSQL Documentation: pg_basebackup — Vendor documentation · postgresql.org · checked 2026-10-03
  5. PostgreSQL Documentation: 25.3. Continuous Archiving and Point-in-Time Recovery (PITR) — Vendor documentation · postgresql.org · checked 2026-10-03
  6. PostgreSQL Documentation: 25.2. File System Level Backup — Vendor documentation · postgresql.org · checked 2026-10-03
  7. PostgreSQL Documentation: pg_verifybackup — Vendor documentation · postgresql.org · checked 2026-10-03
  8. US-CERT / CISA: Data Backup Options (Ruggiero and Heckathorn) — Independent · cisa.gov · checked 2026-10-03
  9. SimpleBackups Pricing — Vendor pricing page · simplebackups.com · checked 2026-10-03
  10. Backup Restore | SimpleBackups Help Center — Vendor documentation · simplebackups.com · checked 2026-10-03