Guides / pg_dump vs pg_basebackup vs pgBackRest

pg_dump, pg_basebackup or pgBackRest: which PostgreSQL backup to run

Updated 31 October 2026 ยท the runs below used PostgreSQL 17.11

pg_dump exports one database as SQL you can load anywhere: another server, a newer version, a managed provider. pg_basebackup copies the whole cluster's files, restores faster and is the starting point for point-in-time recovery, but only onto the same major version and only where you control the server. pgBackRest is pg_basebackup plus the WAL archive, retention and parallel restore, done for you.

If you can only connect to the database (Supabase, Neon, RDS), it is pg_dump. If you run the server and cannot lose the hours between dumps, add pgBackRest.

Here is how they compare on what you get back, what each needs from the server, and how you check the result:

pg_dumppg_basebackuppgBackRest
KindLogical: SQL and data, one databasePhysical: the data directory, whole clusterPhysical, with WAL archiving, retention and parallel restore
Restores toThe moment the dump beganThe moment the copy ended, or any later point if you archive WAL yourselfAny moment in the retention window (point-in-time recovery)
Restores onAny platform, the same or a newer major versionThe same major version and architectureThe same major version and architecture
GranularityOne database, schema or table at a timeAll or nothingAll or nothing, to a point in time
NeedsA connection and a role that can readA replication connection and a free WAL sender; file-system access to restoreFile-system access on the server; a repository host or an S3 bucket
Works on managed PostgresYes: Supabase, Neon, RDS, Railway, Render and the restUsually not: no replication connection or file systemNo
Backup sizeCompressed data, no indexes; rebuilt on restoreEverything on disk, indexes includedFull, differential and incremental, so a day's increment is small
Restore speedSlowest: rows are inserted and indexes rebuiltFast: files are copied into placeFast, parallel, plus WAL replay to the target time
Load on the sourceOne snapshot read; no locks that block the applicationA full file read; needs a free WAL senderA full read for a full backup, less for incrementals
Tested byRestoring into a scratch database and counting rowsStarting a server on the copypgbackrest verify for the files; a restore to check the data
What each tool restores to, on a timeline that ends at the moment something went wrong. pg_dump restores only the moment the dump began. pg_basebackup restores the moment the copy ended, or later only if you archive WAL yourself. pgBackRest restores any second from the base backup on, by replaying the archived WAL. earlier the moment it went wrong backup starts backup ends pg_dump only the moment the dump began pg_basebackup the moment the copy ended pgBackRest any second from the backup on, with WAL
Everything written after the restore point is lost. Only the WAL archive closes that gap, which is why pg_basebackup alone does not give point-in-time recovery.

The two, side by side on one database

A 500,000-row table with one index, 208 MB on disk, in a stock postgres:17 container:

pg_dump -U postgres -Fc -f shop.dump shop
real 0m0.643s
shop.dump  12M

pg_basebackup -U postgres -D base -Ft -z --wal-method=stream
real 4m32.100s
base.tar.gz  29M   pg_wal.tar.gz  158K   backup_manifest  178K

pg_basebackup -U postgres -D base2 -Ft -z --wal-method=stream --checkpoint=fast -P
171540/171540 kB (100%), 1/1 tablespace
real 0m3.579s
The dump holds the rows and the index definition; the base backup holds the index itself and the rest of the cluster. Output trimmed to the times and sizes.

The four and a half minutes are not the copy. By default pg_basebackup asks for a spread checkpoint and waits for it, which takes up to checkpoint_timeout times checkpoint_completion_target (4.5 minutes with the defaults) and prints nothing meanwhile. --checkpoint=fast does it at once, at the cost of a burst of writes. On a quiet test database the same copy then took 3.6 seconds.

Sizes from the run above, drawn to scale. The table and its index take 208 MB on disk. The compressed base backup is 29 MB, plus 158 KB of WAL and a 178 KB manifest. The custom-format dump is 12 MB. on disk 208 MB pg_basebackup 29 MB pg_dump -Fc 12 MB
The base backup carries the index and the rest of the cluster. The dump carries only the index's definition, so the index is rebuilt on restore, which is where a dump's slower restore comes from.

pg_dump

pg_dump connects like any client and reads the whole database from one snapshot, so a dump taken while the application writes is consistent as of the moment it started. It takes no locks that block reads or writes. The output is either SQL or an archive pg_restore can load selectively and in parallel. Because it is SQL, it loads into a newer major version, onto another operating system, and into a different provider. It is the only one of the three that works against a managed database you cannot log in to.

What it cannot do is recover to a point between dumps. A dump at 02:00 and a mistake at 14:00 loses twelve hours. It also rebuilds every index on restore, which is where a restore of a large database spends most of its time. And pg_dump writes one database. Roles and other cluster-wide objects come from pg_dumpall --globals-only. How to back up a PostgreSQL database has the flags, the role and the restore.

pg_basebackup

pg_basebackup ships with PostgreSQL and copies the data directory over a replication connection, the same mechanism a standby uses. With --wal-method=stream it also captures the WAL written during the copy, so the result starts on its own. Restoring means stopping the server, replacing its data directory with the copy, and starting it, which is fast because nothing is rebuilt, and all or nothing because the files are the cluster.

On its own it is a snapshot, like a dump, only bigger and tied to the version and architecture it came from. It becomes point-in-time recovery when you also archive WAL continuously (archive_command or pg_receivewal) and keep the archive beside the base backups, which is the part people get wrong by hand: a missing WAL segment makes every point after it unreachable. PostgreSQL 17 adds native incremental base backups, which shrink the nightly copy. It is the right tool to seed a standby, and a fine one for a cluster you run yourself. It needs the replication privilege and a free WAL sender connection (max_wal_senders).

pgBackRest

pgBackRest is what you run when you want point-in-time recovery without assembling it yourself. It takes full, differential and incremental backups, archives WAL to a repository on another host or in an S3-compatible bucket, keeps as many of each as its retention says, verifies the files it holds, and restores in parallel to any moment in the window. Railway's point-in-time recovery is pgBackRest underneath.

The costs are those of any physical backup. It runs on the database server with access to the data directory, so it cannot back up a database where you only have a connection. It restores onto the same major version and architecture, and a restore is the whole cluster. Its verify command checks that the files are intact and the WAL chain is complete. That is not a restore, and it does not show the data is there, so schedule a restore to a scratch server as part of running it.

What catches people out

Which to run

Whichever you pick, until a backup has been restored nobody knows whether it restores. A dump restores into a scratch database with row counts compared to the source; a physical backup restores onto a scratch server that has to start. Schedule either. How to test that a backup restores has the checks, from a checksum to a row-for-row comparison.

How SafeGrd fits

SafeGrd takes the logical backup: the schema with pg_dump and the rows over binary COPY from one snapshot, encrypted on the host and written under Object Lock. Each backup uploads only what changed. On a schedule, SafeGrd restores the newest one into a throwaway database, checks every table's row count against the manifest written at backup time, and signs the result.

On a PostgreSQL server you run, it can also archive WAL: set archive_command to safegrd wal push, and safegrd wal restore --to brings the database back to any second in the window (details). On a managed database you get the logical backup only. SafeGrd vs pgBackRest says where each stops.