Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What is the difference between a logical backup (pg_dump) and a physical backup with WAL archiving for PostgreSQL? What do RPO and RTO mean here?

pg_dump produces a logical backup: SQL statements or a custom-format archive of one database, portable across PostgreSQL versions but slow to restore when large and frozen at one moment. A physical backup copies the data files with pg_basebackup, pgBackRest or Barman, and with continuous WAL archiving it allows point-in-time recovery to any moment. RPO is how much data we can lose, roughly the WAL not yet archived, and RTO is how long the restore takes.

Why this question is asked

Every team says it has backups, but the kind of backup decides what we can actually recover and how fast. A team with a nightly pg_dump of a 2 TB database may discover during an incident that the restore takes most of a day and loses up to 24 hours of orders. Interviewers ask this to check that we know the two families of PostgreSQL backups, what each one can and cannot do, and how they relate to recovery targets. In this answer, we will recap logical and physical backups, see how WAL archiving makes point-in-time recovery possible, define RPO and RTO with numbers, and finish with when to use each and why a backup is not real until it is restored.

1Logical Backups With pg_dump

A logical backup describes the data rather than copying the files. pg_dump connects to one database like a normal client, takes a consistent snapshot, and writes out the schema and the rows. In plain format it is a SQL script of CREATE TABLE and COPY statements; in custom (-Fc) or directory (-Fd) format it is an archive that pg_restore can restore selectively and in parallel.

Because it contains SQL rather than file pages, a logical dump is portable: we can dump from PostgreSQL 15 and restore into 18, or restore one table into a different server. That makes it useful for upgrades, for copying data between environments and for extracting a single table. But it has two limits. It captures one moment, the snapshot at the start of the dump, so anything written after that is not in it. And restoring means replaying every row and rebuilding every index, which for hundreds of gigabytes can take many hours.

Text
pg_dump -Fc -d shop -f shop.dump # one database, custom format, consistent snapshot
pg_restore -l shop.dump | head # list what is inside the archive
pg_restore -d shop_copy -j 8 shop.dump # restore with 8 parallel jobs
pg_restore -d shop_copy -t customers shop.dump # restore just one table

2Physical Backups and WAL Archiving

A physical backup copies the database cluster's data files as they are on disk. pg_basebackup does this over the replication protocol; tools such as pgBackRest and Barman add compression, incremental backups, retention, encryption and parallel restore. A physical backup covers the whole cluster (every database on that server) and must be restored to the same major PostgreSQL version.

On its own, a base backup is only a copy of one moment, and the files copied while the database was running are not consistent with each other. What makes it powerful is WAL, the write-ahead log. Every change in PostgreSQL is first written to WAL, in segments of 16 MB by default. With archive_mode on and an archive_command or archive library, each finished segment is copied to safe storage. To restore, we lay down the base backup and replay the archived WAL from the backup's start up to any chosen point. That is point-in-time recovery, PITR: we can recover to 14:04:59 yesterday, not only to last night.

Properties
# postgresql.conf (with pgBackRest as an example)
wal_level = replica
archive_mode = on
archive_command = 'pgbackrest --stanza=main archive-push %p'
archive_timeout = 60 # force a segment switch at least every 60 s on quiet systems
# take a full backup
pgbackrest --stanza=main --type=full backup
Step throughHow point-in-time recovery works
  1. Base backup taken Sunday 01:00copy of the data files
  2. WAL segments archived continuouslyevery change since the backup
  3. Incident on Wednesday at 14:05choose a target just before it
  4. Restore base backup to a new serverfiles from Sunday
  5. Replay archived WAL up to 14:04:59recovery_target_time
  6. Promote and open the databasestate exactly as at the target

6 steps in order. Play them, or step through them one at a time.

3What RPO and RTO Mean Here

The recovery point objective, RPO, is how much data we can afford to lose, measured in time. With continuous WAL archiving, the data at risk is whatever WAL has not reached the archive yet: the current, unfinished segment plus any segments still waiting to be copied. With archive_timeout at 60 seconds and a healthy archive, RPO is about a minute; tools that stream WAL continuously, or a synchronous standby, can bring it close to zero. With a nightly pg_dump only, RPO is up to 24 hours.

The recovery time objective, RTO, is how long it takes to be back in service. For a physical restore, RTO is roughly the time to copy the base backup files back plus the time to replay the WAL since that backup. For a 2 TB database, copying at 500 MB/s takes over an hour, and replaying several days of WAL can add more, which is why we take full or incremental backups often enough to keep replay short. For pg_dump, RTO includes loading every row and rebuilding every index, which grows quickly with size.

Logical versus physical backup
Propertypg_dump (logical)Base backup + WAL (physical)
Scopeone database, or chosen tableswhole cluster
Point in timesingle snapshot at dump startany moment covered by archived WAL
Typical RPOtime since the last dumpabout a minute or less
Restore speed for 1 TBmany hours, indexes rebuiltfile copy plus WAL replay
Across major versionsyesno, same major version
Good forupgrades, moving tables, small DBsdisaster recovery, PITR

4Choosing Between Them, and Proving They Work

For any database of meaningful size, physical backups with WAL archiving are the primary protection, because they are the only way to meet an RPO of minutes and an RTO of an hour or two. Logical dumps are still useful alongside them: a dump of a small reference schema before a risky migration, moving one table to another system, or a major version upgrade done by dump and restore when the database is small enough.

But neither kind of backup is proven until we have restored it. Backups fail silently: an archive_command that has been failing for a week, a retention rule that deleted the base backup we needed, an encryption key nobody can find. The only way to know our real RPO and RTO is to restore regularly into a separate server, replay WAL to a chosen time, run checks such as row counts and a few application queries, and record how long it took.

5Follow-up questions

Can I use pg_dump for point-in-time recovery?

No. A dump contains exactly the state at the moment its snapshot was taken. To recover to a later moment we need a physical base backup plus the WAL archive. A dump can only be combined with other logical data, such as an audit table, by hand.

Is a streaming replica a backup?

Not by itself. A replica copies every change, including a mistaken DELETE, within seconds. It protects against losing a server, but not against bad writes or corruption that replicates. We need backups with history for those.

What does archive_timeout do?

It forces PostgreSQL to switch to a new WAL segment after the given number of seconds even if the current segment is not full, so that the segment gets archived. On a quiet database this keeps RPO bounded; the cost is more, partly empty, segments in the archive.

6Conclusion

In this answer, we compared logical backups with pg_dump, which are portable and selective but frozen at one moment and slow to restore when large, with physical base backups plus continuous WAL archiving, which allow point-in-time recovery to any moment. We defined RPO as the data we can lose, about the WAL not yet archived, and RTO as the time a restore takes, and saw why large databases need physical backups while dumps remain useful for moving tables and upgrades. A backup only counts once it has been restored.

What to say in the interviewAbout 80 seconds aloud

Open with

A logical backup with pg_dump connects as a client, takes a consistent snapshot of one database and writes it out as SQL or a custom archive. It is portable across versions and lets me restore single tables, but it captures only one moment and restoring a large database is slow because every row is reloaded and every index rebuilt.

Then, if they want more

A physical backup with pg_basebackup, pgBackRest or Barman copies the cluster's data files, and combined with continuous WAL archiving I can restore the base backup and replay WAL to any moment, which is point-in-time recovery.

RPO is how much data I can lose: with WAL archiving it is roughly the WAL not yet archived, often under a minute, while with a nightly dump it is up to a day. RTO is how long recovery takes: for a physical restore, copying the files plus replaying WAL since the last base backup.

For a large database only physical backups give a reasonable RTO, but I still use dumps for moving a table or for upgrades of smaller databases. And I would say a backup is not proven until it has been restored, so I would schedule regular test restores and measure the real RPO and RTO.

About this answer

Last updated
12 November 2026
Versions it names
PostgreSQL 15
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is the difference between a logical backup (pg_dump) and a physical backup with WAL...": https://scrivio-interview-library.netlify.app/databases/database-operations/0a66756a8a/