What is the newest moment I can get back to, and how long until the database is serving again?
Everyone has backups. Fewer people know how long a restore takes, because they have never timed one. This page picks a side, shows what each engine offers, does the restore-time arithmetic, and lists what breaks.
I take a physical backup (a copy of the data files) every day or every week, and I archive the log continuously (WAL, binlog or oplog) to storage in another account. Together they let me restore to any moment, not just to last night. That is point-in-time recovery, PITR.
Two numbers decide the design. RPO, recovery point objective: how much recent data you can afford to lose. RTO, recovery time objective: how long you can be down. The archive sets the RPO, usually seconds to a few minutes. The size of the database and how much log has to be replayed set the RTO.
And the part that is skipped most: restore it, regularly, on purpose, and time it. A backup nobody has restored is a hope, not a backup.
In one line. A daily base backup plus a continuous log archive, in another account, with a restore tested every month and its time written down.
| Kind | What it is | Good for | Weak at |
|---|---|---|---|
| Physical | A copy of the data files, taken while the server runs, plus the log needed to make it consistent | Fast restores of big databases. The base for PITR. | Same major version and platform only. Restores everything, not one table. |
| Logical | SQL statements or documents: pg_dump, mysqldump, MySQL Shell dump, mongodump | Moving data between versions or engines. Restoring one table. | Slow to restore at size: every index is rebuilt. Not point in time on its own. |
| Storage snapshot | A disk or cloud volume snapshot | Very fast to take. Managed services use them under the hood. | Consistent only if the log is on the same snapshot or the database is told first. Same region and account unless copied. |
pg_basebackup, or pgBackRest, Barman or WAL-G, which add compression, parallelism, retention and checks.archive_command or archive_library copies each WAL segment as it fills.restore_command and recovery_target_time, create recovery.signal, start.pg_basebackup --incremental and pg_combinebackup, with summarize_wal = on.util.dumpInstance(), parallel and much faster than mysqldump. mysqlpump is gone in 8.4.mysqlbinlog --stop-datetime up to the moment before the mistake.binlog_expire_logs_seconds (30 days by default) and copy them off the server.mongodump --oplog gives a consistent dump of a replica set, but not of a sharded cluster.Managed services do most of this for you. Amazon RDS and Aurora, for example, restore to any second inside a retention window of up to 35 days, usually to within the last five minutes. What they do not do is tell you how long the restore takes for your size, or test that your application works after one.
The numbers on this page are arithmetic from the assumptions written next to them, not measurements. Put in your own sizes and speeds, and time a real restore before you trust any of them.
| Step | Assumption | Time |
|---|---|---|
| Copy the base backup to the new server | 2 TB at 400 MB/s from object storage | about 1 h 25 min |
| Replay the log since the base backup | a daily base; 20 hours of WAL at 30 GB an hour, replayed at 150 MB/s | about 1 h 10 min |
| Start, check, point the application at it | scripted and rehearsed | 15 to 30 min |
| Total | about 3 hours |
Two levers move this most. More frequent base backups shorten the replay. Faster storage and parallel restore (pgBackRest and XtraBackup both restore in parallel) shorten the copy. If three hours is too long, the answer is often not a better backup but a standby you can promote in seconds, with backups as the second line for the mistakes a standby faithfully copies, such as a dropped table.
| What happens | Why | What I do |
|---|---|---|
| The restore fails halfway | A WAL or binlog file is missing from the archive; the archive command failed silently for days | Alert on archive failures (pg_stat_archiver.failed_count, the last archived time). Run a restore check that replays to the latest point. |
| The restore works but takes 9 hours | Nobody timed it; a weekly base means days of log to replay | Time a restore every month. Take base backups often enough to keep replay inside the RTO. |
| Backups deleted with the database | Same account, same credentials; ransomware or a mistake removes both | Copy to another account with object lock or immutable retention. |
| Restored to the wrong moment | Clocks, time zones, or a target after the bad statement | Find the exact transaction or binlog position of the mistake first; restore to just before it. |
| The data is back but the app is not | Users, grants, extensions, secrets or DNS were not part of the plan | The runbook covers the whole service, not only the data files. |
| Logical dump of a big database "as the backup" | Restoring rebuilds every index; a 500 GB restore can take most of a day | Logical dumps for portability; physical backups for recovery. |
DROP TABLE within a second. It protects against a dead server, not against a mistake.What I look at every week, and what a monthly restore test runs:
-- PostgreSQL: is the archive keeping up?
SELECT archived_count, last_archived_wal, last_archived_time,
failed_count, last_failed_wal, last_failed_time
FROM pg_stat_archiver;
-- pgBackRest: what backups exist, and are they complete?
pgbackrest --stanza=main info
-- MySQL: oldest binlog still on the server, and how long they are kept
SHOW BINARY LOGS;
SHOW VARIABLES LIKE 'binlog_expire_logs_seconds';
-- MongoDB with PBM: backups and the PITR window
pbm status
pbm listpg_basebackup, combined with pg_combinebackup.archive_library as an alternative to a shell archive_command.mysqlpump; use MySQL Shell's dump utilities.expire_logs_days with binlog_expire_logs_seconds.Your database is 800 GB and grows 40 GB a day in WAL. The business can lose at most 5 minutes and be down at most 2 hours. You take a weekly base backup. Does this meet the targets? What would you change?
Write your answer down first. Then open mine.
RPO: with continuous archiving, a lost server costs at most the WAL segment being filled, usually well under 5 minutes. To be sure, set archive_timeout (for example 60 seconds) so a quiet database still ships a segment every minute. RPO is met.
RTO: a week of WAL is up to 280 GB to replay at the end of the week. At 150 MB/s that is over 30 minutes, plus copying 800 GB (about 35 minutes at 400 MB/s), plus checks: probably fine on day one and tight on day seven. Measure it.
What I would change: a daily base backup, or incremental backups on PostgreSQL 17, to keep the replay short; a standby for the dead-server case, so the backup is only for mistakes; and a monthly timed restore so the 2 hours is measured, not assumed.
The same mechanism, backups and restore, elsewhere on the site: in real incidents, in measurements, and in designs.
Pick an answer. You will see whether it is right, and why.
1. A developer drops a table. Your synchronous standby is perfectly in step. Does it help?
A replica copies every change, mistakes included. Point-in-time recovery from a backup is what brings the table back.
2. What sets how much data a PITR-based plan can lose?
Base backups set how much log must be replayed, so they affect restore time. The log archive sets the recovery point.
3. Why is a logical dump a poor main backup for a 1 TB database?
The dump has the data and the index definitions. Rebuilding indexes on restore is what makes it slow.
4. What is the single most useful backup habit?
A tested, timed restore tells you whether the backups work and how long you will be down.
How do I run it in production? What to check when it is slow or broken, where it runs and what it costs, how big it must be, pooling, backups, security, upgrades and other changes made safely.