skip to content

In Barman, what is the difference between collecting WAL with archiver = on and with streaming_archiver = on, and when would you enable both?

level: seniorimportance: should knowfreq 40%

answer

  1. push from PostgreSQL or pull by Barman
  2. whole segments versus in-progress WAL
  3. incoming versus streaming directory
  4. a slot holds WAL on the primary
  5. duplicates stored once

basics

~20 s

archiver = on takes completed WAL segments pushed by archive_command, ideally barman-wal-archive, into the incoming directory. streaming_archiver = on runs pg_receivewal through a replication slot, receiving WAL as it is written for a lower RPO. Enabling both adds a fallback; Barman stores each segment once.

solid answer

~40 s

With `archiver = on`, PostgreSQL pushes each **completed** WAL segment (16 MB by default) through `archive_command`; the recommended command is `barman-wal-archive barman-host SERVER %p` from barman-cli, which calls `barman put-wal` over SSH, fsyncs the file on arrival and lands it in the server's `incoming` directory. With `streaming_archiver = on`, `barman cron` keeps a `receive-wal` process running `pg_receivewal` over the replication connection, writing the current segment as a `.partial` file, so the RPO drops to seconds, or to zero if `streaming_archiver_name` (default `barman_receive_wal`) is listed in the primary's `synchronous_standby_names`. Streaming needs a slot (`slot_name`, and `create_slot = auto` or a manual slot), or WAL can be recycled before Barman receives it. The docs now recommend streaming alone; adding `archiver` gives a fallback if the receiver or slot breaks, and Barman de-duplicates.

code

ini · 8 lines
ini
[ticketing-pg]
backup_method = postgres
conninfo = host=ticketing-db user=barman dbname=postgres
streaming_conninfo = host=ticketing-db user=streaming_barman dbname=postgres
streaming_archiver = on
slot_name = barman_ticketing
create_slot = auto
archiver = on

go deeper

for a junior

Know that WAL reaches Barman either pushed by archive_command or pulled by pg_receivewal, and that one of the two is required.

for a middle

Explain where each path lands files, why streaming needs a slot, and what barman-wal-archive guarantees that rsync does not.

for a senior

Diagnose a dead receiver or a stuck archive_command from barman check output, and weigh slot-driven WAL retention on the primary against lower RPO.

for a principal

Decide when RPO zero through a synchronous Barman receiver is worth the write-latency coupling, and when a real replica is the better spend.

## Two ways WAL reaches Barman A base backup is useless for point-in-time recovery without the **WAL** written after it, so every Barman server must collect WAL through at least one of two paths. Both options default to `off`; if a server sets neither, Barman sets `archiver = true` to keep its historical behaviour. | | `archiver = on` | `streaming_archiver = on` | |---|---|---| | Direction | PostgreSQL pushes | Barman pulls | | Mechanism | `archive_command` on the database host | `pg_receivewal` on the Barman host | | Unit shipped | completed segments | WAL as it is written | | Lands in | `incoming/` | `streaming/` (current segment as `.partial`) | | Database settings | `archive_mode = on`, `archive_command` | `wal_level = replica`, replication access, a slot | | Transport | usually SSH | replication protocol, no SSH | In both cases `barman cron` moves files from `incoming/` or `streaming/` into the real archive, `wals/`, compressing them if `compression` is set. ## `archiver = on` and `barman-wal-archive` PostgreSQL runs `archive_command` once per completed segment (16 MB by default), so a quiet server ships nothing until a segment fills or `archive_timeout` forces a switch. Since Barman 2.6 the recommended command is **`barman-wal-archive`** from the `barman-cli` package installed on the database host: - it calls `barman put-wal` on the Barman host over SSH, so only the server name is needed and the file cannot land in the wrong directory; - the file is **fsynced** on arrival and its checksum verified, which a bare rsync does not guarantee; - a duplicate with identical content is accepted with exit 0; a duplicate with different content goes to `errors/` and makes `barman check` fail; - `--test` checks the path end to end, compression flags such as `--zstd` compress on the client side, and since Barman 3.20 `--parallel N` ships up to N-1 extra ready segments concurrently to drain a backlog. If the command fails, PostgreSQL keeps retrying and keeps the segment in `pg_wal`, so an unreachable Barman host shows up as WAL piling up on the database server. ## `streaming_archiver = on`, `receive-wal` and the slot `barman cron` starts and supervises a `receive-wal` process per server, which runs `pg_receivewal` over `streaming_conninfo` (or `wal_streaming_conninfo`). Because WAL arrives as it is written, the window of loss shrinks from up to a segment to seconds. Listing the receiver's application name, `streaming_archiver_name` (default `barman_receive_wal`), in the primary's `synchronous_standby_names` makes Barman a synchronous receiver for **RPO zero**; the docs stress it is no substitute for a real replica. Streaming on its own does not stop the primary from recycling WAL Barman has not received yet. A **physical replication slot** does: set `slot_name`, and either create the slot yourself (`create_slot = manual`, the default, with `barman receive-wal --create-slot SERVER`) or let cron create it with `create_slot = auto`. The flip side is that a dead receiver turns the slot into a reason for the primary to keep WAL indefinitely; capping that is the slot leaf's subject (`max_slot_wal_keep_size`). Barman also advises streaming from the **primary** so no WAL is missed across a failover. ## Running both Older Barman releases recommended both paths because PostgreSQL before 9.4 had no slots. Today the docs recommend **streaming only** for general use, and adding `archive_command` as a fallback is optional: if the receiver or slot breaks, segments still arrive. Barman checks for duplicates and stores each segment once. A reasonable rule for a fleet of 30 servers: streaming through a slot everywhere, plus the `archive_command` fallback only on the servers whose RPO matters most, such as ticketing, or whose network path to the Barman host is least reliable. The fallback costs SSH keys and the `barman-cli` package on each of those database hosts, so it is worth adding where it buys something rather than by default. ## What goes wrong in practice 1. **`receive-wal` died.** `barman check` reports `replication slot` with the hint that the slot is not active and asks whether `receive-wal` is running, plus a failed `receive-wal running` line. The next `barman cron` restarts it; meanwhile the primary retains WAL for the slot. 2. **Switched from archiver to streaming but left files behind.** With `archiver = off` and files still in `incoming/`, `barman check` fails. Check whether they are newer than the oldest backup's `begin_wal` or already archived, clear them, and remove `archive_command` on the database side. 3. **An inactive server.** Since 3.20, `barman cron` stops the `receive-wal` of a server set to `active = false`, but the slot still holds WAL on the primary until you re-enable the server or drop the slot.

  • What does barman check report if the receive-wal process has died while its slot still exists?
    The `replication slot` check fails with a hint that the slot is not active and asks whether `receive-wal` is running, and the `receive-wal running` check fails too. The next `barman cron` restarts the receiver. Until then the inactive slot makes the primary keep WAL in `pg_wal`, so a long outage is also a disk-space risk on the database host.
  • You set archiver = off after moving a server to streaming, and barman check now fails on the WAL archive. Why?
    WAL files are still sitting in the server's `incoming/` directory. With the archiver off, Barman treats them as unsaved and fails the check. Confirm whether they are newer than the oldest backup's `begin_wal` or already in the archive, remove them once safe, and drop the `archive_command` on the database server so no more arrive.
  • What does barman-wal-archive add over a plain rsync archive_command?
    It sends the file through `barman put-wal`, which fsyncs it on arrival, verifies a checksum and writes it to the right `incoming/` directory from just the server name. Identical duplicates succeed with exit 0, conflicting ones go to `errors/` and fail `barman check`. It also has `--test`, client-side compression and, since 3.20, `--parallel` to drain a backlog.

  • streaming_archiver without a replication slot is as safe as archive_command
  • With both archiver and streaming_archiver on, Barman stores every segment twice
  • barman-wal-archive runs on the Barman host and pulls WAL from PostgreSQL
  • archiver = on alone gives an RPO of a few seconds on a quiet server
  • Barman enables streaming_archiver by default when nothing is configured