Safeguard
Developer Tools•

Logical or physical backups for PostgreSQL: which should you use?

SQL dumps, file system copies and continuous archiving each protect different things. A comparison of speed, portability, restore scope and recovery point.

Safeguard Security Team
3 min read

Use SQL dumps for portability and single database restores, file system level or base backups for fast whole cluster restores, and continuous archiving when you need to recover to a chosen point in time. Many teams combine a base backup with archiving and keep periodic dumps as a second path.

The three approaches

The PostgreSQL manual names three: SQL dump, file system level backup, and continuous archiving with point in time recovery.

SQL dump (logical). A dump is a snapshot of one database as of when it started, and does not block most other work. It does not include roles or tablespaces, which are cluster wide, so the manual points to dumping those separately. Text dumps restore with psql, custom and directory formats with pg_restore. Roles that own objects must exist before restoring.

File system level backup (physical). Copies the files PostgreSQL uses. The manual says the server must be shut down to get a usable backup by default, or you can use a consistent snapshot, which the server treats like a crash and recovers from by replaying write ahead log. It works only for the whole cluster, with no partial restores.

Continuous archiving. A base backup plus archived write ahead log lets you recover to a point in time. It needs more setup and monitoring.

Comparison

QuestionSQL dumpFile system or base backupContinuous archiving
Restore one databaseYesNoNo, whole cluster
Cross version restoreGenerally yesNo, tied to versionNo
Speed on large dataSlowerUsually fasterFast base plus replay time
Recovery pointTime of dumpTime of backupChosen point
Includes rolesSeparate stepYesYes

The manual states dump output generally restores into newer PostgreSQL versions, while file level backups and archiving are tied to a specific server version.

How to choose

  1. Write your RPO and RTO for the database.
  2. If RPO is under your backup interval, you need archiving.
  3. If RTO is tight and the data is large, you need physical restores, since replaying a long dump takes time.
  4. If you must restore a single database, or move between versions, keep dumps too.
  5. Test each path by restoring into a clean environment and timing it.

Common mistakes

  • Taking a file copy of a running server without a snapshot or the proper start and stop backup steps. The result may be unusable.
  • Forgetting roles and tablespaces when relying on per database dumps.
  • Snapshotting data and write ahead log volumes separately. The manual says snapshots must be simultaneous across file systems.
  • Treating a replica as the backup. It copies deletes and corruption too.

Safeguard can scan the application dependencies and infrastructure definitions around your database. You can start with a free scan.

Quick check

Is pg_dump enough for a production database?

It can be, if your RPO allows restoring from the last dump and restore time is acceptable. Many teams add archiving for a tighter recovery point.

Can I restore a base backup on a newer major version?

Not directly. File level backups are tied to the server version, so use a dump or an upgrade tool for version changes.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.