What is Barman in a PostgreSQL backup setup, and what does running barman check against a newly configured server tell you?
answer
- one backup host, many databases
- a named server section each
- OK or FAILED, line by line
- exit status feeds monitoring
- switch-wal on a fresh server
basics
~20 sBarman is a backup manager whose one host keeps physical base backups and archived WAL for many PostgreSQL servers. barman check SERVER tests a server's connections, WAL shipping, directories and settings, printing OK or FAILED per line and exiting non-zero on failure.
solid answer
~50 sBarman (Backup and Recovery Manager, from EnterpriseDB) runs on a dedicated host and manages **physical** backups for many PostgreSQL servers. Each protected database is a named *server* section, typically one file per server in `/etc/barman.d/`, with its own directory of base backups and WAL; most commands take that name (`barman backup ticketing-pg`, `barman list-backups ticketing-pg`). `barman check ticketing-pg` (or `barman check all`) is the readiness and health test: it validates the normal and streaming connections and privileges, `wal_level`, `archive_mode`/`archive_command` or the replication slot and `receive-wal` process, that WAL is actually arriving, the directories, retention settings and optional freshness limits such as `last_backup_maximum_age`. Each line is `OK` or `FAILED` with a hint, and the command exits non-zero if anything fails, so `barman check --nagios` plugs into monitoring. On a fresh server, a failed `WAL archive` line usually just means no segment has completed yet: `barman switch-wal --force` and then `barman cron` clear it.
code
bash · 4 linesbarman list-servers
barman check ticketing-pg
barman switch-wal --force --archive ticketing-pg
barman check --nagios allgo deeper
Recall that Barman is a central host managing physical base backups and WAL for many PostgreSQL servers, each under its own name, and that barman check is the command you run first.
Explain which areas barman check covers, why its exit status matters for automation, and how switch-wal and cron fix the usual first-day failures.
Show how you would wire barman check into alerting for dozens of servers, including freshness limits, so a silently stopped backup job pages someone.
Discuss where a configuration health check ends and restore testing begins, and how you would report backup health across a whole estate.
## What Barman is **Barman** (Backup and Recovery Manager) is EnterpriseDB's open-source tool for **physical** PostgreSQL backups. It runs on its own host and manages base backups plus archived **WAL** (write-ahead log, the stream of changes PostgreSQL writes before touching data files) for many PostgreSQL servers at once. A base backup plus continuous WAL is what makes point-in-time recovery possible. Barman never uses `pg_dump`; logical dumps are a different tool for a different job. The full `barman` package lives only on the Barman host; database hosts need at most the small `barman-cli` package, whose `barman-wal-archive` and `barman-wal-restore` scripts ship and fetch WAL. At a regional public-transport operator, one Barman host might protect 30 servers: ticketing, timetable planning, vehicle telemetry, depot maintenance. Each needs its own connection details, backup method, WAL path and retention, and Barman keeps them strictly apart. ## The server catalogue - Every protected database is a **server**: a named section such as `[ticketing-pg]`, usually one file per server in `/etc/barman.d/`, with global defaults in the `[barman]` section of `/etc/barman.conf`. - Each server gets its own directory under the Barman home, holding `base/` (base backups), `wals/` (the WAL archive), `incoming/` and `streaming/` (WAL waiting to be archived) and `errors/`. - Almost every command takes the server name: `barman backup ticketing-pg`, `barman list-backups ticketing-pg`, `barman restore ticketing-pg ...`. `barman list-servers` lists them all. - `barman cron`, scheduled from the system crontab, does the background work: moving and compressing incoming WAL, keeping `receive-wal` running, checking that new backups have their WAL, and applying retention. It does **not** take backups; you schedule `barman backup` yourself. ## What `barman check` verifies `barman check SERVER` (or `barman check all`) runs a list of named checks and prints each as `OK` or `FAILED`, usually with a hint: | Area | Example check lines | Typical cause of FAILED | |---|---|---| | Connections | `PostgreSQL`, `superuser or standard user with backup privileges`, `PostgreSQL streaming` | wrong `conninfo`, missing `pg_hba.conf` rule, user lacks privileges | | Server settings | `wal_level`, `archive_mode`, `archive_command` | archiving switched off, `wal_level` too low | | WAL arriving | `WAL archive`, `continuous archiving`, `replication slot`, `receive-wal running` | nothing shipped yet, slot missing or inactive | | Local tools | `pg_basebackup`, `pg_basebackup compatible` | client binaries older than the server | | Barman side | `directories`, `retention policy settings`, `compression settings`, `archiver errors` | bad option value, files left in `errors/` | | Freshness | `backup maximum age`, `minimum redundancy requirements` | no recent backup, too few full backups | It also compares the **system identifier** seen over the normal connection, the streaming connection and on disk, so a connection string pointed at the wrong cluster is caught before it pollutes the archive. The command **exits non-zero if any check fails**, and `--nagios` turns the output into a Nagios/Icinga plugin line. Freshness checks only bite if you set them: `last_backup_maximum_age = 1 DAYS` fails the check when the newest backup is older than a day, `last_wal_maximum_age` does the same for WAL, and `minimum_redundancy` sets the floor for the redundancy check. Without them, a nightly backup job that silently stopped would still leave `barman check` green. ## Reading failures on a new server 1. Add the server with `active = false`. Commands that ingest data (`backup`, `put-wal`, `receive-wal`, cron work) are disabled, but `check` still runs, so the log does not fill with archiving errors while you iterate. 2. `WAL archive: FAILED` right after setup usually means no WAL segment has been completed and shipped yet. `barman switch-wal --force ticketing-pg` (which calls `pg_switch_wal()` on the server) followed by `barman cron` normally clears it. 3. `replication slot: FAILED` with the hint to run `barman receive-wal --create-slot` means the slot named in `slot_name` does not exist; with `create_slot = auto`, `barman cron` creates it for you. A slot that exists but is not active points at a dead `receive-wal` process. 4. When every line is `OK`, set `active = true` and take the first backup with `barman backup ticketing-pg`. ## What a green check does not prove A clean `barman check` says the configuration is coherent, the connections work and WAL is flowing. It does not prove that last night's backup restores; only a restore proves that. `barman check-backup` is narrower again: it confirms that one backup has every WAL file its consistency needs, and Barman runs it automatically after backups and from `barman cron`.
- Why does Barman's documentation suggest adding a new server with active = false first?With `active = false`, Barman disables the commands that ingest data (`backup`, `put-wal`, `receive-wal` and cron work) but keeps read-only commands such as `check` and `list-backups` available. You can iterate on `barman check` without filling the log with archiving errors, then switch to `active = true` once every line is `OK`.
- Which barman check lines tell you a backup schedule has silently stopped, and how do you turn them on?`backup maximum age` fails when the newest backup is older than `last_backup_maximum_age` (for example `1 DAYS`), `last_backup_minimum_size` catches a suspiciously small one, and `last_wal_maximum_age` catches stalled WAL. `minimum redundancy requirements` fails when there are fewer non-incremental backups than `minimum_redundancy`. All are unset or zero by default, so you must configure them.
- Barman takes pg_dump logical backups of each database
- Barman must be installed in full on every PostgreSQL server it protects
- barman check exits 0 even when a line is FAILED
- barman cron takes the scheduled base backups
- A green barman check proves last night's backup will restore