With WAL-G delta backups on PostgreSQL, what does WALG_DELTA_MAX_STEPS control, and what does a longer delta chain cost you at restore time?
answer
- off unless set above zero
- count deltas, then a full
- page LSN against the base's start
- LATEST vs LATEST_FULL origin
- every link fetched at restore
basics
~20 sWALG_DELTA_MAX_STEPS (default 0, disabled) is how many delta backups may follow a full before backup-push takes a full again. Longer chains upload less but make restores fetch and apply every link, and one missing link breaks them.
solid answer
~50 sA WAL-G delta stores only the pages changed since its base backup, found from file modification times and page LSNs; its name is `base_<start>_D_<base start>`. With `WALG_DELTA_MAX_STEPS=6`, each `backup-push` after a full makes a delta until six are chained, and the next push is full again; `--full` forces one sooner. `WALG_DELTA_ORIGIN=LATEST` (default) chains each delta off the previous backup, while `LATEST_FULL` bases every delta on the full one, so a restore needs only the full plus one delta. At restore, `backup-fetch` downloads the full and applies every delta in order, so restore time grows with the chain, any lost or deleted link makes everything after it unrestorable, and you still replay WAL from the last delta's start. Deltas also need WAL-G to read the data directory itself: not over the replication protocol, not with `--without-files-metadata`, and not from a permanent base unless the new backup is permanent too.
code
bash · 5 linesexport WALG_DELTA_MAX_STEPS=6 # full + up to 6 deltas, then full again
export WALG_DELTA_ORIGIN=LATEST # chain each delta off the previous backup
wal-g backup-push "$PGDATA" # delta or full, decided by the step count
wal-g backup-push "$PGDATA" --full # force a full now
wal-g delete retain FULL 4 --confirm # keep four whole chainsgo deeper
Recall that WALG_DELTA_MAX_STEPS is 0 by default, meaning every backup-push is a full backup, and that a delta stores only changed pages.
Explain how WAL-G finds changed pages from page LSNs, how the step count decides between delta and full, and what LATEST and LATEST_FULL change.
Reason about restore time and fragility as the chain grows, keep retention in whole chains, and know the cases where WAL-G silently takes a full backup.
Set the chain length from measured backup windows and measured restore times, and weigh WAL-G deltas against PostgreSQL 17's native incremental backup.
## What a delta is in WAL-G A **delta backup** in WAL-G stores only the data pages that changed since a base backup. To decide what changed, WAL-G compares file modification times and the **LSN stamped on every page** against the start LSN of the base backup: a page whose LSN is newer has been written since. Unchanged files are recorded as skipped in the backup's metadata. The name records the lineage: `base_000000010000000100000072_D_000000010000000100000063` is a delta whose base started at segment `...63`. A delta is not usable alone. Restoring it means unpacking its base (and that base's base, back to a full backup) and laying each delta's pages on top, then replaying WAL from the newest backup's start as usual. ## WALG_DELTA_MAX_STEPS and the chain `WALG_DELTA_MAX_STEPS` defaults to **0, which disables deltas**: every `backup-push` is full. Set it to N and the logic at each push is: 1. Find the base (by default the latest backup) and read its increment count. 2. If that count plus one is more than N, log `Reached max delta steps. Doing full backup.` and take a full. 3. Otherwise take a delta and record the new count. With N = 6 and a nightly push, the week looks like: full on Sunday, deltas Monday to Saturday, full again the next Sunday. `backup-push --full` forces a full at any time, and `--delta-from-name` or `--delta-from-user-data` pick a specific base. ## WALG_DELTA_ORIGIN: chain or star | `WALG_DELTA_ORIGIN` | Each new delta is based on | Restore of the newest needs | Upload size | |---|---|---|---| | `LATEST` (default) | the previous backup | the full plus **every** delta in between | smallest per delta | | `LATEST_FULL` | the last full backup | the full plus **one** delta | grows through the cycle | `LATEST_FULL` suits databases whose changing part is compact, where successive deltas would mostly rewrite the same pages anyway; the docs describe the deltas as overwriting each other. ## Restore cost A longer chain trades upload volume for restore risk and time: - **More downloads and writes.** `backup-fetch` applies the full and then each delta in order. The beta `--reverse-unpack` (with `--skip-redundant-tars`) unpacks newest first to skip work, but the chain still has to exist. - **More single points of failure.** A missing, corrupt or deleted delta makes every later backup in that chain unrestorable. This is why `delete retain N` refuses to cut a chain in the middle and `retain FULL N` keeps whole chains. - **The same WAL rule.** Deltas do not remove the need for WAL from the newest backup's start onward. - **Longer retention.** Keeping seven fulls with `retain FULL 7` keeps every delta between them as well. A worked example with `WALG_DELTA_MAX_STEPS=6`, nightly pushes and the default `LATEST` origin: restoring Saturday's backup means downloading Sunday's full and six deltas, seven backups applied in sequence, and losing Wednesday's delta makes Wednesday to Saturday unrestorable while Sunday to Tuesday still work. With `LATEST_FULL` the same Saturday restore needs Sunday's full and one larger delta, and a lost Wednesday delta costs only Wednesday. ## When WAL-G takes a full backup instead WAL-G silently falls back to a full backup, or refuses a delta, in several cases: - the step limit is reached (above); - the base backup has no recorded start LSN or its metadata cannot be read; - the base is permanent and the new backup is not (unless `WALG_DELTA_ORIGIN=LATEST_FULL`); - the backup streams over the replication protocol (no data directory argument), where deltas are not implemented; - `--without-files-metadata` is set, which cannot be combined with `WALG_DELTA_MAX_STEPS`. Reading the `backup-push` log after enabling deltas is the quickest way to see which one applies. ## Choosing N For a small startup's PostgreSQL in a container, a reasonable process is: 1. Measure a full backup's duration and size, and a typical day's changed volume. 2. Pick N so that the weekly full fits its window and a restore of the longest chain still meets your recovery-time target. Measure that restore, do not estimate it. 3. Keep retention in whole chains (`retain FULL`). 4. Run `wal-verify` so the WAL behind the newest delta is known to be complete. PostgreSQL 17's own incremental `pg_basebackup` with `pg_combinebackup` solves the same problem with a different mechanism and belongs to core base backups.
- What are wal-g catchup-push and catchup-fetch for?They repair a lagging PostgreSQL replica without a full re-clone. You stop the replica, read its LSN (for example with `pg_controldata`), run `wal-g catchup-push <primary PGDATA> --from-lsn <LSN>` on the primary to upload only pages changed since then, and `wal-g catchup-fetch <replica PGDATA> <backup name>` on the replica. It uses the same page-LSN comparison as delta backups.
- You set WALG_DELTA_MAX_STEPS=6 but every backup-push is still full. Why?Check the log. Common causes: `backup-push` runs without a data directory, so it streams over the replication protocol where deltas are not implemented; `--without-files-metadata` is on; the latest backup is permanent; or its metadata cannot be read. Each makes WAL-G take a full backup.
A delta chain is a stack of tracing-paper overlays on a base map: each sheet only draws what changed since the sheet below. To see today's map you need every sheet in order, and one lost sheet in the middle makes every sheet above it meaningless.
- WAL-G takes delta backups by default once a full exists
- WALG_DELTA_MAX_STEPS counts the full backup as one of the steps
- Restoring the newest delta needs only that delta and the WAL after it
- Deltas remove the need to archive WAL between backups
- Remote backup-push over the replication protocol produces deltas too