Database Backup Strategies: Full, Incremental, and PITR

Learn database backup strategies: full, incremental, and differential backups. Point-in-time recovery, WAL archiving, and RTO/RPO planning.

published: reading time: 33 min read author: Geek Workbench updated: November 7, 2026
Quick Summary

Reliable database recovery starts with backups that match measured RPO and RTO targets and can be restored in practice. This guide compares full, incremental, and differential backups, explains PostgreSQL WAL archiving and point-in-time recovery, and estimates transfer, restore, and replay time. It also covers protected backup copies, monitoring, and isolated restore drills. Use these checks to validate recovery coverage before an outage forces the test.

Backup and Recovery: Full, Incremental, Differential, and Point-in-Time

Introduction

A backup job that reports success has not proved the database can be recovered. A team may need a clean restore after accidental deletion, corruption, or a regional outage, and the available recovery point depends on both the base backup and the logs kept since then.

This guide compares backup types and PostgreSQL point-in-time recovery, then shows how to set recovery targets, protect backup copies, and measure restore time in drills. The goal is to know what can be restored, how much data may be lost, and how long service recovery actually takes.

Runnable Recovery Lab: PostgreSQL 18 PITR

This lab restores an isolated PostgreSQL 18 cluster to a named recovery point after a table is dropped. It uses a physical base backup plus archived WAL; the AWS and Azure sections later are comparison notes, not alternate steps in this procedure. Use a disposable PostgreSQL 18 server, its matching version 18 client tools, and local paths owned by the operating-system account that runs PostgreSQL. The backup connection needs a role with REPLICATION privilege (the lab uses postgres for brevity); configure password authentication outside the command line.

1. Enable WAL archiving on the lab server

Create /srv/pg18-lab/wal so the PostgreSQL server account can write to it. Add these settings to the lab server’s postgresql.conf, then restart the server because archive_mode takes effect at startup:

# PostgreSQL 18 server configuration
wal_level = replica
archive_mode = on
archive_command = 'test ! -f /srv/pg18-lab/wal/%f && cp %p /srv/pg18-lab/wal/%f'

The command uses PostgreSQL’s %p source path and %f WAL filename placeholders. For a production archive, use storage outside the database host’s failure boundary and monitor archive failures; this local directory is only for the lab.

2. Create known data and take a base backup

Connect to the lab server on port 5432 and create a row that should survive recovery:

-- PostgreSQL 18
CREATE TABLE pitr_lab (id integer PRIMARY KEY, note text NOT NULL);
INSERT INTO pitr_lab VALUES (1, 'present before the incident');

Take the full physical backup into a new or empty directory. -X stream includes the WAL needed to make the backup consistent. Verify its manifest and files before relying on it:

# PostgreSQL 18 client utilities
pg_basebackup -h localhost -p 5432 -U postgres \
  -D /srv/pg18-lab/base -Fp -X stream -P
pg_verifybackup /srv/pg18-lab/base

pg_verifybackup checks the backup against its manifest, including the WAL needed to recover the base backup. It does not prove that later archived WAL can restore to the target; the isolated restore below checks that full chain.

3. Mark the recovery point, make the bad change, and archive WAL

Run each command separately so the restore point is committed before the destructive change:

# PostgreSQL 18 client utility; the connected role must be allowed to create restore points
psql -X -h localhost -p 5432 -U postgres -d postgres \
  -c "SELECT pg_create_restore_point('before_drop');"
psql -X -h localhost -p 5432 -U postgres -d postgres \
  -c "DROP TABLE pitr_lab;"
psql -X -h localhost -p 5432 -U postgres -d postgres \
  -c "SELECT pg_switch_wal();"
psql -X -h localhost -p 5432 -U postgres -d postgres \
  -c "SELECT last_archived_wal, last_archived_time, last_failed_wal, last_failed_time FROM pg_stat_archiver;"

Wait until the WAL segment containing the drop has been archived, and investigate any matching archive failure before continuing. pg_switch_wal closes the current segment so the archiver can copy it; pg_stat_archiver reports the most recent archive and failure attempts.

4. Restore to the named point in a separate data directory

Copy the backup into a new, empty directory as the PostgreSQL operating-system account. Edit the copied postgresql.conf to read the archive and stop at the named restore point. archive_mode = off prevents this drill from writing a new timeline into the source archive:

# Unix file operations; run as the account that owns the PostgreSQL 18 cluster
mkdir -p /srv/pg18-lab/restore
cp -a /srv/pg18-lab/base/. /srv/pg18-lab/restore/
# PostgreSQL 18: append to /srv/pg18-lab/restore/postgresql.conf
archive_mode = off
restore_command = 'cp /srv/pg18-lab/wal/%f %p'
recovery_target_name = 'before_drop'
recovery_target_action = 'promote'

Create the signal file and start this copy on a different port. Do not start the restored data directory on the source server’s port or direct application traffic to it before validation.

# PostgreSQL 18 client utility
touch /srv/pg18-lab/restore/recovery.signal
pg_ctl -D /srv/pg18-lab/restore -l /srv/pg18-lab/restore/server.log \
  -o "-p 55433" start
psql -X -h localhost -p 55433 -U postgres -d postgres \
  -c "SELECT * FROM pitr_lab;"
pg_ctl -D /srv/pg18-lab/restore stop -m fast

The query should return the original row. The lab is complete only when the restore starts, reaches before_drop, and the expected data is present; a successful backup command alone is not a recovery test.

Backup Types Explained

Full Backups

A full physical base backup captures the database cluster’s files. In the PostgreSQL 18 recovery lab above, pg_basebackup creates that full backup. A logical backup such as PostgreSQL 18’s pg_dump captures selected database objects in a portable format. The right baseline depends on the restore method and tooling you choose.

Advantages:

  • Complete restoration in a single operation
  • Simple to understand and verify
  • Can restore to the base-backup point without earlier backups
  • Self-contained disaster recovery

Disadvantages:

  • Largest storage footprint
  • Longest backup duration
  • Maximum impact on production system I/O
  • Cannot be applied incrementally

Choose a recovery chain that can be verified end to end. For the physical PITR method in the lab, that means a compatible base backup and every required WAL segment through the target. A different selected method may have a different dependency set.

Incremental Backups

An incremental backup captures changes relative to an earlier backup. PostgreSQL 17 and 18 support incremental physical backups with pg_basebackup --incremental, using an earlier backup’s manifest. The PostgreSQL 18 command below uses -X stream to include the WAL needed to make the backup consistent.

# PostgreSQL 18 client utility: incremental backup based on the prior manifest
pg_basebackup -h localhost -p 5432 -U postgres -D /srv/pg18-lab/incremental \
  --incremental=/srv/pg18-lab/base/backup_manifest -Fp -X stream -P

Incremental backups depend on their reference backups and must be combined with PostgreSQL 18’s pg_combinebackup before recovery. Supply the full backup and then every required incremental backup from oldest to newest:

# PostgreSQL 18 client utility
pg_combinebackup -o /srv/pg18-lab/combined \
  /srv/pg18-lab/base /srv/pg18-lab/incremental
pg_verifybackup /srv/pg18-lab/combined

The incremental chain still needs its required archived WAL for PITR. PostgreSQL does not track or retain the chain dependencies for you; see the PostgreSQL 18 pg_combinebackup documentation before adopting this optional path.

Advantages:

  • Minimal storage consumption
  • Fast backup operations
  • Low production system impact
  • Frequent backups possible

Disadvantages:

  • Restore requires chain of all backups from last full
  • Complex restore procedures
  • Backup chain corruption means data loss
  • Longer recovery time

To restore, you need the reference full backup and every incremental backup in order, then combine them with PostgreSQL 18’s pg_combinebackup before recovery. The simpler base-backup-plus-WAL path in the lab avoids this extra chain-management step.

Differential Backups

A differential backup captures changes since the last full backup. PostgreSQL 18’s pg_basebackup does not provide a differential-backup mode; use a backup tool that documents this strategy if you need it.

Differential backup: changed data since the latest full backup
Restore set: latest full backup + latest differential backup

Advantages:

  • Smaller than full backups
  • Simpler restore than incremental (only need full + one differential)
  • Moderate backup duration
  • Good balance of storage and complexity

Disadvantages:

  • Larger than incremental backups (grows over time)
  • Backup duration increases as differential grows
  • Still requires full backup + one differential to restore

Differential backups offer a middle ground: you trade some storage for restore simplicity.

Understanding Point-in-Time Recovery

Point-in-time recovery (PITR) allows you to restore a database to any specific moment—not just the moment when a backup completed. This is essential for recovering from user errors, partial data corruption, or transactions that shouldn’t have happened.

How PITR Works

PITR relies on Write-Ahead Logging (WAL). Every database modification is written to a sequential log file before being applied to data files. WAL records transaction and recovery metadata along with the database changes needed to replay updates. Physical recovery replays those records in sequence; it does not store a simple, human-readable list of every SQL statement or row change.

The PostgreSQL 18 lab above shows this sequence with a physical base backup, an archived WAL segment, a recovery.signal file, and a named recovery target. A base backup by itself only restores the cluster to its backup state; PITR needs the unbroken WAL archive from the backup through the target. PostgreSQL 18 reads recovery settings from postgresql.conf, not the removed recovery.conf file.

WAL Archiving Considerations

WAL archiving is the backbone of robust backup strategies. Key considerations:

Archive Storage: WAL volume depends on the workload and can differ substantially from database write volume. Measure generated WAL over representative peak and quiet periods, then size the archive for that measured rate and your retention window.

Archive Verification: Untested WAL archives are worthless. Regularly verify that archived WAL can actually restore.

# PostgreSQL 18 utility. Remove archived WAL older than a known restart point; this is cleanup, not verification.
pg_archivecleanup /archive/wal 00000001000000000000001C

Archiving and replication serve different recovery needs: PITR replays archived WAL from a base backup. Streaming replication can keep a standby current for failover; its retention and recovery behavior depend on configuration.

Method Typical use Key consideration
WAL archiving Point-in-time recovery Archive frequency and gaps determine the recoverable window.
Physical streaming replication Standby and failover Replication lag and failover behavior must be monitored and tested.
Logical replication Selective data replication It is not a substitute for physical backups and WAL-based PITR.

RTO and RPO Planning

Recovery Time Objective (RTO) and Recovery Point Objective (RPO) are business-defined recovery targets. They may become contractual commitments, so set them with service owners and validate them through realistic recovery tests.

Defining Your Objectives

RTO (Recovery Time Objective): Target time to restore service after an outage. This is a duration—typically hours or minutes.

RPO (Recovery Point Objective): Maximum acceptable data loss measured in time. If your RPO is 1 hour, you accept losing up to 1 hour of transactions.

These aren’t technical decisions—they’re business decisions. Work with stakeholders to define realistic objectives based on:

  • Cost of downtime per hour
  • Cost of data loss per transaction
  • Regulatory requirements
  • Customer expectations

Translating to Technical Requirements

Once you have RTO and RPO targets, translate them into a restore chain and schedule that meet those targets. These are example mappings; the selected backup method and tested recovery behavior determine the actual requirements.

RPO Technical Requirement
0 (no data loss) Synchronous replication or synchronous commit
15 minutes Frequent WAL archiving or managed PITR + tested recovery
1 hour Recovery points and logs that bound loss to one hour, verified in a restore drill
24 hours A verified recovery point within the previous day for the selected method
RTO Technical Requirement
Minutes HA architecture, automatic failover
Hours Tested restore procedures, on-call staff
Days Documented manual recovery procedures

The Math of Recovery

Calculate realistic recovery times:

def estimate_recovery_time(
    full_backup_size_gb: float,
    differential_size_gb: float,
    network_mbps: float,
    restore_speed_mb_per_s: float,
    wal_replay_seconds: int
) -> dict:
    restore_set_size_gb = full_backup_size_gb + differential_size_gb
    transfer_time = (restore_set_size_gb * 1024 * 8) / network_mbps  # seconds; network Mbps
    restore_time = (restore_set_size_gb * 1024) / restore_speed_mb_per_s  # seconds; MB/s
    wal_time = wal_replay_seconds

    estimated_restore_minutes = (transfer_time + restore_time + wal_time) / 60

    return {
        "transfer_minutes": round(transfer_time / 60, 1),
        "restore_minutes": round(restore_time / 60, 1),
        "wal_replay_minutes": round(wal_time / 60, 1),
        "estimated_restore_minutes": round(estimated_restore_minutes, 1)
    }

This estimate assumes a full backup plus one differential. For an incremental chain, include every required incremental in the restore-set size. Use measured transfer and restore speeds; differential or incremental application may change effective throughput. This is not a complete RTO, so add setup, validation, and application cutover time from a restore drill.

Managed-Service Comparison Notes: AWS RDS and Azure SQL

The PostgreSQL 18 lab above is the runnable recovery path in this article. These notes compare managed-service backup models; exact controls depend on the service, database engine, tier, and region.

Amazon RDS (comparison note)

Amazon RDS automated backups support point-in-time recovery within the configured retention period, and manual snapshots can be retained separately. Check the selected engine and deployment type before setting retention or planning cross-region recovery. See the Amazon RDS backup and restore guide and backup retention documentation.

Azure SQL Database (comparison note)

Azure SQL Database manages full, differential, and transaction-log backups for point-in-time restore. Retention, geo-restore availability, and long-term retention depend on the database configuration and backup storage redundancy. Azure SQL uses SQL Server backup behavior, so its procedures are separate from the PostgreSQL 18 lab. See Microsoft’s automated backup overview and restore guide.

Questions to answer before choosing a managed service

Evaluation question Why it matters
What are the configured backup and PITR retention windows for this engine and service tier? Defaults and maximums vary by provider, engine, region, and configuration.
Can recovery use a separate region or account? Regional recovery needs a copy or restore path outside the failure boundary.
How long does an actual restore take, including application cutover? A provider feature list does not establish your RTO.
Can required recovery points be retained for the applicable compliance period? Long-term retention may need a separate archive and restore procedure.

When to Use / When Not to Use Each Backup Type

Full Backups — Use when:

  • You need a standalone recovery point
  • Recovery time is more important than backup time
  • Storage is not a constraint
  • You’re establishing a new backup baseline

Full Backups — Do not use when:

  • Your database is very large (>10TB) and backup windows are tight
  • You’re doing incremental backup chains

Incremental Backups — Use when:

  • RPO targets are tight (under 1 hour)
  • Storage costs must be minimized
  • Backup window is limited

Incremental Backups — Do not use when:

  • Your backup chain complexity is a operational risk
  • You need faster recovery over storage savings

Differential Backups — Use when:

  • You need a middle ground between full and incremental
  • Restore simplicity matters but storage savings still appeal

Differential Backups — Do not use when:

  • Differential growth becomes nearly as large as a full backup
  • Your RPO requires more granular recovery

Trade-Off Table

Dimension Full Backup Incremental Backup Differential Backup
Backup size Largest Smallest Grows over time
Backup speed Slowest Fastest Moderate
Restore complexity Simplest — one step Complex — chain required Moderate — full + one diff
Storage cost Highest Lowest Moderate
RTO (restore time) Lowest Highest Moderate
Best for Small DBs, baseline Large DBs, tight RPO Medium RPO, moderate complexity

Recovery Copy Trade-Offs

Copy strategy Recovery benefit Cost or risk
Online copy in the production account Quick access for routine restores The same credentials or outage may affect both production and backup copies
Immutable or offline copy Resists deletion or modification by compromised production credentials Retrieval and restore may take longer; retention and recovery keys need separate planning
Cross-region copy Keeps a recovery point outside a regional failure Adds transfer and storage cost, and still needs tested permissions, keys, and restore steps

Production Failure Scenarios

Failure Impact Mitigation
WAL gap from missed archive PITR restore impossible at exact point Monitor archive status continuously, alert on gaps
Backup chain corruption Full data loss — restore impossible Verify backup integrity on every job, store checksums
Storage exhaustion during backup Backup fails, disk fills Monitor disk space, alert at 70% threshold
Restore failing due to permissions DR procedure fails when needed most Test restore with minimal permissions weekly
Cloud snapshot restore taking hours Extended downtime exceeds RTO Pre-stage recovery environment, test RTO monthly
Incremental backup overflow Disk fills, backup deleted Set retention enforcement, monitor growth rate

Capacity Estimation: Backup Storage Sizing and WAL Growth Rate

Backup storage sizing depends on your backup strategy, retention period, and database growth rate.

Full backup storage formula:

full_backup_size = database_size × compression_factor
compressed_full_backup_size = database_size / compression_ratio

Do not size storage from a generic compression ratio. Measure a PostgreSQL 18 backup using the selected format and compression settings on representative data, then include retention, WAL, growth, and restore staging space in the estimate.

WAL growth rate formula:

WAL_daily_growth_bytes = measured_WAL_bytes_per_second × 86400

Measure WAL generation rather than inferring it from database write throughput. For example, 100MB/s of WAL generation is about 8.64TB per day before compression. PostgreSQL 18’s wal_keep_size controls retained WAL for replication; it does not set the retention period for an external archive.

Incremental backup sizing: Track the change rate per day, not the total database size:

-- PostgreSQL 18: current WAL position since cluster initialization, not since checkpoint
SELECT
    pg_size_pretty(
        pg_wal_lsn_diff(pg_current_wal_lsn(), '0/00000000')::bigint
    ) AS wal_bytes_since_cluster_start;

Typical change rates: OLTP databases 1-5% of database size per day. Data warehouses with nightly batch loads: 20-50% per day during loads, 0% between loads. Knowing your change rate lets you size incremental backups correctly.

Observability Checklist

Key backup metrics: job success/failure, backup duration trends, restoration time, and backup size anomalies. The metric names below are examples from a site-specific exporter; map them to metrics your own collectors actually expose.

  • Record each restore drill’s start and finish, target recovery point, integrity checks, and outcome; flag missed drills.
  • Compare the recovered timestamp with the incident cutoff to measure actual RPO, and watch archived-WAL time and gaps between drills.
  • Measure end-to-end RTO through retrieval, restore, WAL replay, validation, and application cutover against the service target.
  • Monitor immutable-copy retention locks and alert if a recovery identity can delete or shorten retention on protected copies.
  • Track backup-chain verification and ensure the monitoring system reports failures when a job or restore test does not complete.
-- Track job duration and size using your backup tool's status/history command.

For PostgreSQL 18 archiving, pg_stat_archiver exposes the last successful and failed archive attempts; it does not report end-to-end restore readiness.

# Critical: backup job failed
- alert: BackupJobFailed
  expr: backup_job_status != 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: "Backup job {{ $labels.job }} failed: {{ $labels.error }}"

# Warning: backup duration increased significantly
- alert: BackupDurationAnomaly
  expr: backup_duration_seconds > 1.5 * avg_over_time(backup_duration_seconds[7d])
  for: 10m
  labels:
    severity: warning
  annotations:
    summary: "Backup taking {{ $value }}s vs typical {{ $labels.typical }}s"

# Warning: backup size anomaly (could indicate data growth or corruption)
- alert: BackupSizeAnomaly
  expr: backup_size_bytes > 2 * backup_size_bytes_offset_1d
  for: 1h
  labels:
    severity: warning
  annotations:
    summary: "Backup size {{ $value }} bytes is 2x yesterday's {{ $labels.yesterday }}"

# PostgreSQL 18 source view: pg_stat_archiver; exporter metric names vary.
# Critical: WAL archive failures (PITR at risk)
- alert: WalArchiveFailures
  expr: pg_archiver_failed_count > 0
  for: 5m
  labels:
    severity: critical
  annotations:
    summary: "PostgreSQL WAL archiving has failed; check archive health and PITR coverage"

Security and Compliance Notes

  • Confidentiality: Encrypt database backups, snapshots, and WAL archives in transit and at rest. Keep encryption keys and their recovery path separate from production database credentials; an encrypted backup is unusable if its key is lost.
  • Integrity and tamper resistance: Verify checksums before restoring, and keep an immutable or offline copy in a separate account or administrative boundary. Production credentials should not be able to alter or delete every recovery copy.
  • Access: Separate backup-write and restore permissions. Restrict destructive actions such as deleting snapshots or changing retention, require an approved break-glass path for them, and audit reads, restores, and policy changes.
  • Retention and recovery: Set retention and legal holds to match applicable data rules, including WAL archives and cross-region copies. Restore into an isolated recovery environment, verify the data and application before directing production traffic to it.

Quick Recap Checklist

Use this checklist when designing or reviewing backup and recovery for a database system:

  • A compatible base backup or other selected recovery point is available and verified
  • Every dependency required by the selected restore method is retained and verified
  • WAL archiving is enabled and verified when PITR is part of the recovery plan
  • Backup integrity verified via checksum validation after every job
  • Restore procedure tested in isolated environment within last 30 days
  • RTO and RPO documented and communicated to stakeholders
  • Cross-region backup copies exist for disaster recovery
  • Backup retention policy aligned with compliance requirements
  • Backup monitoring alerts configured for job failures and capacity
  • Recovery runbook documented with step-by-step restore procedures

Testing Recovery Procedures

Here’s the uncomfortable truth: a backup that cannot be restored is not a backup. This is non-negotiable.

Regular Recovery Testing

Weekly verification: Automated test restore to confirm backup chain validity.

#!/bin/bash
# Weekly backup verification script
set -euo pipefail

# PostgreSQL 18 client utility: validate the latest physical base backup manifest.
# Set this path from your backup inventory.
pg_verifybackup /backups/latest

Monthly full disaster simulation: Complete restore to isolated environment, verify data integrity, measure actual RTO against targets.

What to Verify

Verification is not a single step. It is a chain of checks that must all pass before you trust a backup. Each stage catches different failure modes, and skipping any of them leaves a gap that only shows up during a real disaster.

Backup completion status confirms the job ran without errors. Check the exit code, the job log, and the backup size against expected ranges. A job that exits successfully but produces a 1KB file is not a successful backup — it is a false positive. Alert thresholds should trigger when backup size drops below 80% of the moving average.

Backup chain integrity validates that all required WAL segments are present and usable. Do not use pg_archivecleanup for verification; it deletes archived WAL that is older than the supplied restart point. Check the backup tool’s validation output and test recovery through the intended target time.

Restore completion means the backup actually restores without errors — not just that the backup command exits cleanly. For a PostgreSQL 18 pg_dump archive, PostgreSQL 18’s pg_restore --list inspects its contents; for a physical base backup, PostgreSQL 18’s pg_verifybackup checks the manifest and files. Perform an isolated restore test as well. After restore, compare expected database contents and size against a known baseline.

Data integrity goes beyond row counts. Run checksum validation on critical tables, verify foreign key relationships, and spot-check high-value rows against known-good baseline values. Row count alone does not catch silent data corruption.

Application functionality testing happens after restore: run your application’s standard query suite against the restored database. If your app queries a specific customer record, query that record. If it aggregates daily totals, run that aggregation. This catches restore issues that only surface at the application layer.

Performance baseline establishes that restore does not degrade database performance. Measure query latency on the restored system before and after restore. If p99 query time doubles after restore, the backup is technically complete but operationally useless.

Common Pitfalls / Anti-Patterns

  • WAL gap: Missing WAL segments break the restore chain
  • Corrupted backup: Checksum failures on backup files
  • Storage exhaustion: Restore fails due to insufficient disk space
  • Permission issues: Restored database has wrong ownership
  • Timezone handling: Timestamps differ between backup and restore environments
  • Treating a successful job as proof of recovery: A completed backup can still be incomplete or unusable. Restore it in isolation and verify the data and application.
  • Keeping every copy under the same administrative control: A compromised production identity may delete both live data and backups. Keep an immutable or offline copy across a separate access boundary.
  • Relying on a standby as the only recovery copy: Replication can carry accidental deletion or corruption to the standby. Retain an independent backup and WAL history for point-in-time recovery.
  • Estimating RTO from backup duration alone: Include data retrieval, replay, validation, and cutover in a timed restore drill.

Recovery During GitHub’s 2018 MySQL Incident

GitHub’s October 21, 2018 post-incident analysis says a network partition left writes in both data centers that could not be safely reconciled by failing back. GitHub chose to preserve data integrity, restore multi-terabyte MySQL backups from remote object storage, synchronize replicas, return to a stable topology, and then resume queued jobs. Although its backup procedure was tested daily, the full cluster rebuild still took hours; much of that time went to transfer, decompression, checksum, preparation, and load.

The recovery lesson is to include those steps in the runbook and in the timed drill: retrieve the off-site copy, verify it, restore the full cluster, rebuild or synchronize replicas, validate the serving topology, then release queued work. Record end-to-end time for each step and gate application traffic until data is consistent. A delayed replica can help with recovery, but it does not remove the need to test the complete backup restore path.


Interview Questions

1. Your RPO is 15 minutes and your database writes 100GB/day. How do you design the backup strategy?

An RPO of 15 minutes means the latest recoverable point must be no more than 15 minutes behind the failure. Take compatible base backups and archive WAL continuously, then monitor archive failures and test recovery against that target. Measure WAL generation directly; total database write volume does not reliably predict it. PostgreSQL 18 supports incremental physical backups, but each still depends on its reference backup and a tested recovery chain. The backup schedule alone does not establish the achieved RPO.

2. During a PostgreSQL 18 PITR restore, the required WAL archive has a gap. What happened and how do you recover?

A missing required WAL segment prevents replay beyond the last point recoverable from the available archive. In the PostgreSQL 18 PITR lab, identify the last verified base backup and determine whether another retained archive copy supplies the missing segment. If not, restore only to a target before the gap or choose a different verified recovery point; never report the requested point as recovered. Investigate archiver errors, permissions, destination capacity, and transfer failures. Monitor archive success and lag, and test the intended recovery range so a gap is found before an incident.

3. Your team uses PostgreSQL and your boss asks why you can't just use `pg_dump` for backups. What are the trade-offs?

PostgreSQL 18's pg_dump creates a logical backup of a database that PostgreSQL 18's pg_restore or psql can load, depending on format. It takes a consistent snapshot, but by itself does not provide physical cluster recovery or PITR through WAL replay. Physical base backups plus archived WAL can support PITR; logical dumps remain useful for portability and selective restore. Choose based on tested restore time and recovery needs, not a fixed database-size cutoff.

4. How do you calculate realistic RTO for a 5TB database restoration across regions?

RTO = transfer time + restore time + WAL replay time + application cutover. At a sustained 100Mbps, transferring 5TB takes roughly 111 hours before protocol overhead; at 1Gbps it is roughly 11 hours. These are idealized estimates, so measure actual throughput and restore performance. If that exceeds the target, pre-position the data or maintain a standby in the recovery region.

5. What is point-in-time recovery, and what does a team need to use it?

Point-in-time recovery restores a database to a chosen time by restoring a suitable base backup and replaying retained WAL through the target. It requires a recovery-compatible backup, an unbroken WAL archive for the required interval, correct recovery settings, and a tested restore process. Without WAL coverage, recovery is limited to the available backup points. Archiving must be configured before an incident; it cannot recover log records that were never saved.

6. Your backup job fails with "disk space exhausted" during a full backup of a 2TB database. How do you prevent this?

Before starting a PostgreSQL 18 backup, confirm the destination has room for the measured backup size, expected growth, and retained recovery data. Alert on capacity trends before the destination fills. The PostgreSQL 18 pg_basebackup -Z option supports compression, but storage savings depend on the selected format, method, and data; measure both backup and restore performance. If a backup fails for lack of space, preserve its logs, verify whether the tool left a usable backup, clear space according to retention policy, then retry to a clean destination. Enforce retention automatically and keep protected recovery copies outside the backup job's deletion scope.

7. A cloud provider experiences a regional outage and your production database is in that region. Walk through your recovery process.

Confirm the provider's outage scope and expected recovery time. If the DR environment is ready, activate it; otherwise, restore from the latest cross-region backup. For read-replica failover, promote the replica and update DNS. Verify that the recovered data meets application requirements, report the measured RTO, and plan data reconciliation after the primary region returns. Test the runbook with a timed restore; without a successful cross-region restore, the actual RTO is unknown.

8. What is the difference between WAL shipping and streaming replication for PITR, and when would you choose each?

WAL shipping transfers archived WAL segments on a schedule; recovery lag depends on how often segments are archived and copied. Physical streaming replication sends WAL over a persistent connection and can keep a standby more current, though lag and failover time still depend on configuration and workload. Choose based on measured RPO/RTO, network reliability, and operational cost. A standby helps with availability, while a separate WAL archive supports longer-term PITR; neither replaces tested backups.

9. Your backup verification job reports success but the backup file is corrupted. What went wrong and how do you prevent it?

A successful exit code and a created file do not prove that a backup is complete; it could be empty, truncated, or corrupted. Check the manifest or checksums, store validation results separately, and run periodic isolated restores. GitHub's 2018 incident shows that a tested backup can still take hours to restore at multi-terabyte scale. Restore tests should check both data correctness and recovery time.

10. How does WAL segment accumulation cause storage issues, and what strategies control it?

Archived WAL is retained so it can be replayed during recovery; it is not consumed by normal PITR operations. High write volume or an archive destination problem can increase storage use or create an archiving backlog. Monitor archive failures and the age of the latest archived segment using your monitoring stack, set retention to cover the required recovery window, and test cleanup policies before they remove needed WAL. Compression can reduce storage use when supported by your backup tooling.

11. Your database writes 500GB/day and you have a 2-hour backup window. What backup strategy works?

500GB/day = ~6GB/hour write rate. A 2-hour backup window captures approximately 12GB of writes — much smaller than the full database if it is multi-terabyte. Strategy: weekly full backups (weekend or maintenance window) plus continuous WAL archiving for PITR, with incremental backups every 2 hours capturing only changed blocks. This gives you PITR capability (WAL replay to any point) without requiring full backups during the backup window. A two-hour backup window does not set the PITR RPO when WAL is archived continuously; measure archive lag and test recovery against the actual target. If RPO must be zero, use synchronous replication instead.

12. What are the trade-offs between backup replication to a separate region versus backup archival to object storage?

Replication to a separate region (e.g., cross-region RDS replica) provides fast failover (RTO minutes) and continuous data protection, but is expensive and replicates continuously. Backup archival to S3/Blob Storage is cheaper, provides point-in-time restore capability, but restore time is dominated by data transfer (hours for multi-TB databases). Best practice: use cross-region replication for HA/failover, and periodic backups to object storage for disaster recovery. This gives you both fast local failover and long-term point-in-time recovery. Never rely on a single backup strategy.

13. How do compression ratios affect your backup storage calculations, and why do estimates often differ from reality?

Compression savings vary with the data, output format, and compression method. For PostgreSQL 18, choose a supported format and compression setting documented for pg_basebackup, then measure the resulting backup on representative data. Include CPU cost and restore throughput in the comparison; do not use a generic compression ratio as a capacity guarantee.

14. Your organization performs quarterly disaster recovery testing. What metrics should you measure during the test?

During the test, record RTO from DR initiation to database availability, RPO as data lost in bytes or time, restore throughput, WAL replay time, DNS cutover, and application reconnection. Compare the measurements with the documented targets. If recovery takes four hours against a one-hour target, update the runbook or change the recovery design. Include cold-storage retrieval time; it can add hours.

15. A user accidentally drops a critical table at 3pm. You need point-in-time recovery to 2:59pm. Walk through the process.

For PostgreSQL 18, check pg_stat_archiver for archive failures, then confirm a compatible physical base backup and every required WAL segment through the target are available. Restore to an isolated data directory, set restore_command and recovery_target_time = '2026-03-26 14:59:00 UTC' in postgresql.conf, and create an empty recovery.signal file in that directory. Start the restored cluster on a separate port, verify the table and its data, and export the recovered table or validate the whole cluster before directing traffic to it. PostgreSQL 18 uses recovery.signal and settings in postgresql.conf, not recovery.conf. Total time depends on database size and WAL volume since the backup.

16. Your backup chain is intact but the most recent full backup failed verification. How do you recover?

If the most recent PostgreSQL 18 physical base backup fails verification, select the latest earlier verified base backup whose required WAL and any incremental dependencies are still available. Restore that chain and replay only the WAL retained through the chosen target. This may extend the achieved RPO. Investigate disk errors, checksum mismatches, and backup-process failures; retain verification output and repeat an isolated restore test before treating the alternate chain as usable.

17. Under what conditions does streaming replication outperform backup/restore for disaster recovery?

Physical streaming replication can keep a standby close to the primary, with lag determined by workload and network conditions. Backup and restore can take hours for large databases, so a standby may better meet short failover targets. Replication does not protect against every user error because destructive changes can also reach the standby; use backups and WAL-based PITR for recovery to an earlier point. Choose the design based on tested recovery targets and the cost of maintaining a standby.

18. How does backup to tape versus disk affect your restore strategy, and what are the trade-offs?

Tape costs less per GB and works for long retention, but sequential access can make a point-in-time restore slow if several tapes must be replayed. Disk provides random access and faster verification at a higher storage cost. Cloud object storage has similar random access, though retrieval time and pricing depend on the tier. Keep a faster recovery copy for production restores and use tape for longer compliance retention when it meets the recovery target. Test the actual restore path before relying on tape.

19. Your backup window is shrinking due to database growth. What options exist to maintain backup coverage?

Options: use incremental backups where supported by your backup tool, tune compression and parallelism, reduce base-backup frequency only if tested WAL recovery still meets targets, or improve storage and network throughput. PostgreSQL 18 pg_basebackup supports incremental backups; PostgreSQL 18's pg_backup_start and pg_backup_stop functions define the start and end of a low-level backup but do not themselves create incremental streams. Re-measure duration as the database grows.

20. Your disaster recovery runbook is 10 pages long. How do you test it without causing a production outage?

Restore a recent backup in an isolated environment that mirrors production, verify it against a known point in time, and time the recovery. Automate repeatable steps. For the manual steps, run a tabletop exercise so operators know what to do; schedule full restore tests for maintenance windows. Record where the runbook differs from what happened during testing.


Further Reading


Conclusion

Backup and recovery is not a set-it-and-forget-it operation. It requires ongoing attention, testing, and refinement.

Maintain a verifiable restore chain for the recovery method you selected. Add incremental backups, differential backups, or WAL archiving only when they meet a defined RPO or RTO target. Test the whole chain regularly.

The time to discover your backup strategy fails is not during an actual disaster. Run fire drills. Simulate failures. Know exactly what your RTO and RPO actually are under real conditions, not just on paper.

For deeper exploration of disaster recovery patterns, see our disaster recovery guide. And for monitoring your database health, check out relational databases fundamentals.

Category

Related Posts

Database Capacity Planning: A Practical Guide

Plan database capacity from measured growth, retention, workload, and provisioning time. Includes a storage forecast and PostgreSQL-specific memory guidance.

#database #capacity-planning #infrastructure

Failover Automation

Automatic failover patterns. Health checks, failure detection, split-brain prevention, and DNS TTL management during database failover.

#database #failover #high-availability

Disaster Recovery: RTO, RPO, and Building a Recovery Plan

Disaster recovery planning protects against catastrophic failures. Learn RTO/RPO metrics, backup strategies, and multi-region failover patterns.

#disaster-recovery #reliability #backup