Using Barman's barman-cloud-* scripts without a Barman server, how do you back up a PostgreSQL server to object storage, and what do you give up?
answer
- scripts live on the database host
- archive_command ships WAL to the bucket
- you schedule backup and delete
- no cron, no check, no catalogue host
- recovery settings are yours
basics
~20 sInstall barman-cli-cloud on the PostgreSQL host, set archive_command to barman-cloud-wal-archive, and schedule barman-cloud-backup plus barman-cloud-backup-delete -r for retention. You give up the Barman server: no cron, no barman check, no incrementals, and barman-cloud-restore leaves recovery configuration to you.
solid answer
~40 sThe barman-cloud scripts (package `barman-cli-cloud`) run **on the PostgreSQL host** and keep all data and metadata in the bucket. WAL goes out through `archive_command = 'barman-cloud-wal-archive s3://bucket/barman ticketing-pg %p'`. Base backups come from `barman-cloud-backup s3://bucket/barman ticketing-pg`, run from a scheduler as `postgres` because it reads `PGDATA` and tablespaces directly and uploads tar archives with `-J` workers. Before first use, `barman-cloud-check-wal-archive` confirms the prefix holds no WAL from another cluster. What you lose is the server: no `barman cron`, so retention is `barman-cloud-backup-delete -r 'RECOVERY WINDOW OF 30 DAYS'` on your own schedule; no `barman check`; no incremental backups; and `barman-cloud-restore` only puts files back, leaving `restore_command` (`barman-cloud-wal-restore`), signal files and targets to you. With a Barman server you can instead copy to the cloud from hook scripts or stream backups to a cloud URL.
code
ini · 3 lines# postgresql.conf on depot-pg
archive_mode = on
archive_command = 'barman-cloud-wal-archive --zstd s3://transit-backups/barman depot-pg %p'go deeper
Know that the barman-cloud scripts run on the database host and send backups and WAL straight to object storage without a Barman server.
Name which script goes in archive_command, which takes backups, and which enforces retention.
Spell out what you must rebuild yourself without a Barman server, from scheduling and alerting to recovery configuration, and when the hybrid hook-script setup is the better answer.
Compare script-only cloud backups with a central Barman server for an estate, weighing operational load, incrementals and immutability requirements.
## Two ways to reach object storage Barman can put backups in object storage (S3-compatible stores and the other two object-store APIs the scripts support, selected with `--cloud-provider`) in two broad ways: - **With a Barman server**, which keeps the catalogue and runs maintenance: copy each backup and WAL file to the cloud from hook scripts, stream `backup_method = postgres` backups straight to a cloud `basebackups_directory`, or, since 3.18, use `backup_method = local-to-cloud` with Barman on the database host. - **With the barman-cloud scripts alone**, from the `barman-cli-cloud` package, with no Barman server anywhere. Data and metadata live only in the bucket, and Barman holds no local state. This question is about the second mode, for example for small servers at a regional transport operator's depots, where nobody wants another host to run. ## The pieces | Script | Role | |---|---| | `barman-cloud-wal-archive` | used in `archive_command`; ships each completed WAL segment to the bucket | | `barman-cloud-backup` | takes a base backup by reading `PGDATA` and tablespaces and uploads tar archives | | `barman-cloud-backup-list` / `-backup-show` | list backups in the bucket and show one in detail | | `barman-cloud-backup-delete` | delete by ID or by retention policy, with unused WAL | | `barman-cloud-backup-keep` | mark an archival backup that retention never deletes | | `barman-cloud-check-wal-archive` | verify a WAL prefix is safe for a new cluster | | `barman-cloud-restore` | download and unpack a backup into a directory | | `barman-cloud-wal-restore` | used in `restore_command` to fetch WAL during recovery | ## Setting it up 1. Install `barman-cli-cloud` on the PostgreSQL host and give it credentials for the bucket. 2. Run `barman-cloud-check-wal-archive s3://bucket/barman ticketing-pg`. It succeeds only if the prefix holds no WAL, or with `--timeline`, only WAL from earlier timelines, so a new cluster cannot mix into another's archive. 3. Set `archive_mode = on` and `archive_command = 'barman-cloud-wal-archive s3://bucket/barman ticketing-pg %p'`, with a compression flag such as `--zstd` if wanted. 4. Schedule `barman-cloud-backup s3://bucket/barman ticketing-pg` as the `postgres` user. It needs read access to `PGDATA` and the tablespaces and a database connection to start and stop the backup; `-J` sets upload workers (default 2). 5. Schedule `barman-cloud-backup-delete -r 'RECOVERY WINDOW OF 30 DAYS' s3://bucket/barman ticketing-pg`, trying `--dry-run` first. It removes backups outside the policy and WAL no remaining backup needs; `-m` sets a minimum redundancy. ## What you give up - **`barman cron`**: nothing runs retention, compression or checks for you; every job is yours to schedule and alert on. - **`barman check`**: no built-in health report; watch `archive_command` failures on the database side (for example `failed_count` in `pg_stat_archiver`) and the age of the newest backup in the bucket. - **Incremental backups**: `barman-cloud-backup` always takes a full backup. The docs name streaming backups from a Barman server as the only way to get block-level incrementals in the cloud. - **A prepared restore**: `barman-cloud-restore SOURCE_URL SERVER_NAME BACKUP_ID RECOVERY_DESTINATION` only puts the files back. You must write `restore_command = 'barman-cloud-wal-restore s3://bucket/barman ticketing-pg %f %p'`, any `recovery_target_*` settings and `recovery.signal` yourself. - **Load on the database host**: compression, tar building and uploads all run next to PostgreSQL. - **One place to manage many servers**: every database host carries its own credentials and schedules, so 30 servers mean 30 sets of jobs that must stay identical, and nothing lists them side by side the way `barman list-servers` does. ## Safeguards worth adding - **Object locking (WORM)** on the bucket for immutability; Barman does not create locks, but `barman-cloud-backup-delete --check-object-lock` checks and respects them before deleting. - **Encryption**: the scripts' server-side encryption options (`-e`, `--sse-kms-key-id`); whoever restores needs the same key access. - **Restore drills**: a script-only setup has no catalogue host to tell you something is wrong, so a periodic `barman-cloud-restore` into a scratch host is the only real proof. When these costs bite, the hybrid keeps a Barman server for cron, check and catalogue, and adds `post_backup_retry_script = barman-cloud-backup ...` and `pre_archive_retry_script = barman-cloud-wal-archive ...` to copy everything to the bucket as well.
- How do you keep a Barman server but still get every backup and WAL file into object storage?Use hook scripts on the Barman server: `post_backup_retry_script` running `barman-cloud-backup` copies each finished backup, and `pre_archive_retry_script` running `barman-cloud-wal-archive` copies each WAL file. Alternatively set `backup_method = postgres` with cloud URLs in `basebackups_directory` and `wals_directory`, documented as experimental and limited to S3-compatible storage, which also allows block-level incrementals.
- Why run barman-cloud-check-wal-archive before pointing a cluster at an existing bucket prefix?A prefix that already holds WAL from another cluster, or from this cluster before a restore, would mix two histories under one server name. The check fails if any WAL is present, unless `--timeline` is given and every existing file belongs to an earlier timeline, which is the legitimate case after a recovery opened a new one.
- barman-cloud-backup runs on a separate host and pulls PGDATA over SSH
- barman cron enforces retention for script-only cloud backups
- barman-cloud-restore writes restore_command and recovery.signal for you
- barman-cloud-backup takes block-level incremental backups
- barman-cloud-backup-delete removes backups but never their WAL