PostgreSQL backups with Barman

Barman gives a team one central backup server for many PostgreSQL instances, with streaming or rsync backups, WAL archiving and point-in-time recovery in infrastructure you control. This page covers the decisions, setup and proof of restore that matter.

On this page

PostgreSQL backups with Barman: when a central backup server fits

If you run several PostgreSQL instances and have recovery point and recovery time targets to meet, Barman is a central backup server that takes base backups from each instance and receives the write-ahead log (WAL) files those instances archive. Instead of giving every database host its own backup scripts and local retention, you keep the backup catalog, retention rules and restore tooling in one place. That fits teams who want one place to check backup status across many clusters, and who want restores to be driven from a single, consistent procedure. Point-in-time recovery depends on the same two parts described in the PostgreSQL continuous archiving documentation: a base backup plus archived WAL files covering the time you want to return to. Barman manages both halves, so the question for your team is whether a central server fits how you operate, not whether the mechanism works.

Barman is a good fit when the number of instances is large enough that per-host scripts become hard to audit, when one team owns backup operations for several applications, and when you want a dedicated backup host separate from the database servers. It is a weaker fit when you have a single small instance, or when you need features your team cannot verify in the version you deploy. Before you choose it, confirm in the Barman documentation which backup modes, WAL archiving methods and object storage options the version you plan to run supports, and how each one behaves during a restore. Ask whether your database hosts can reach the backup server or object storage under your network rules, and who holds the credentials to each side.

Whatever tool you choose, a backup is only proven when a restore has been run to a target time and the result checked against your data and your recovery time target. Plan a restore drill on a separate host early, measure how long it takes, and record what the runbook needed that was not written down. Treat the first drill as a test of the tooling and the procedure, not only of the backup files. Repeat drills on a schedule and after any change to the PostgreSQL major version, archive path or backup host. If your recovery point target is tight, confirm how often WAL is shipped and what gap that leaves in the worst case, because the central server can only restore what it has received.

Streaming, rsync and barman-cloud: choosing how backups reach Barman

Streaming mode has the Barman server connect to PostgreSQL over the replication protocol, using a role with replication privileges, and pull a base backup while receiving WAL through a replication slot or a streaming connection. It is the transport that most closely follows the database's own replication model, so the backup server behaves like a standby that keeps a copy of the cluster's changes. Network needs are a single route from the Barman host to each PostgreSQL port, plus authentication rules in pg_hba.conf that allow the replication connection from that host.

  • Network path: the Barman host needs direct database connectivity, normally over TLS, and the database must permit replication connections from it.
  • WAL handling: WAL arrives continuously over the streaming connection, which keeps the gap between the last backed-up change and the failure point small.
  • Slot management: replication slots keep WAL on the primary until it is received, so a stalled backup server can fill the primary's disk.
  • Who should pick it: teams running a central backup host with a stable network path to many instances and enough monitoring to watch slot lag.
  • Version coupling: confirm the Barman release you deploy supports the PostgreSQL major versions in your fleet.

Check the streaming and slot settings against the current Barman documentation before you size the disk on the primary.

How Barman, PostgreSQL servers and WAL archives fit together

The diagram starts at the PostgreSQL primaries, which Barman reaches over the network to take base backups, while WAL either streams to the backup server or arrives through archive_command. The backup server keeps a local copy and can push a second copy to object storage through barman-cloud, which sits behind a separate trust boundary. A restore flows back from the backup server to a target server that you choose and control. Check which credentials cross each boundary, and whether the off-site copy can be reached by anything that can also reach the database hosts.

Barman pulls backups and WAL from primaries, stores copies locally and off site, and restores to a target.

Barman configuration options and when each fits

This table compares the main Barman configuration decisions, from backup method to repository location, and states when each choice fits and what it costs in operations. Read each row against your recovery point and recovery time targets, then confirm the exact settings against the Barman release you plan to run.

DecisionOptionWhen it fitsTrade-off to weigh
Backup methodStreaming backup over the replication protocolInstances you can reach over the network, where you want base backups and WAL shipped without a file-level copy of the data directoryRequires replication access and correct server settings on each instance; confirm the supported PostgreSQL versions for your Barman release
Backup methodrsync backup over SSHHosts where you prefer file-level copies or need to reach the data directory directlyRequires SSH access from the backup server and more careful handling of file permissions and ownership
WAL archiving modeStreaming WAL through a replication slotRecovery point targets that need WAL shipped continuously, with fewer gaps between backupsNeeds replication slot management and monitoring so unconsumed WAL does not fill the server disk
WAL archiving modeArchive command shipping completed WAL segmentsEnvironments that already run a WAL archive path or cannot maintain a streaming connectionRecovery point depends on how often segments close, so the gap between backups can be larger than with streaming
Retention policyRecovery window or redundancy-based retentionSets how far back you can restore and how many base backups are keptLonger retention raises repository size and storage cost; confirm the policy matches your recovery and audit commitments
Repository locationLocal repository on the backup server diskFast local restores and a simple first deployment on storage you controlSingle site unless a second copy is made; disk sizing must cover the full retention window
Repository locationObject storage through barman-cloudOff-site copies in storage you control, with separate credentials and immutability options plannedAdds network transfer, object storage charges and a need to confirm the provider features you rely on
Compression and encryptionCompressed backups and WALReducing storage footprint and transfer time when CPU capacity is available on the backup hostCompression adds CPU load during backup and restore; encryption must be planned with key custody before the first backup
Incremental backup useFull base backups onlySmaller estates or simpler restore chains where storage and transfer are not limitingEach backup carries the full data set, so storage and transfer grow with database size
Incremental backup useIncremental backups with a reconstructed restore chainLarge databases where full backups are costly to store or move, provided the chain is verified and testedRestores depend on an intact chain; confirm the Barman and PostgreSQL versions you run support the method you choose

Setting up Barman for a first PostgreSQL instance

This sequence takes a PostgreSQL instance from no backup coverage to a Barman server that connects, archives WAL, holds a first base backup and passes its readiness checks. Each step ends with a check the team can run before moving on.

  1. Prepare the dedicated Barman host

    The infrastructure or platform team provisions a separate host for the Barman server, apart from the database servers it protects, and confirms it can reach each PostgreSQL instance over the network on the PostgreSQL port. They also create a dedicated operating system user for Barman and set up storage for the backup catalog and WAL archive, sized from the expected backup retention and change rate, which the team should estimate with its own data. Verification: from the Barman host, a basic connection test to the database port succeeds, and the storage volume is mounted with write access for the Barman user.

  2. Install Barman and its dependencies

    The administrator installs Barman on the dedicated host using the packages for the operating system, or the project's documented installation method, along with the PostgreSQL client tools that match the server versions Barman will protect. Confirm the installed version against the Barman documentation for your chosen release, and check that the client binaries can reach the database. Verification: running the Barman version command returns a version string, and the PostgreSQL client version is compatible with the protected server according to the Barman compatibility notes.

  3. Create the backup and replication roles

    A database administrator creates a dedicated PostgreSQL role for Barman with the REPLICATION attribute for streaming, plus the privileges needed to run backups, following least privilege and the authentication method defined in pg_hba.conf for the Barman host address. Use SCRAM password authentication, since MD5 is deprecated in PostgreSQL 18. Store the password in a secrets manager or a protected pgpass file on the Barman host, not in the Barman server configuration in plain text. Verification: connecting as the Barman role from the Barman host with the psql client succeeds, and the replication connection test returns a result.

  4. Configure the server entry in Barman

    The administrator creates a server definition file for the instance, typically under the Barman configuration directory, setting the connection string, the streaming connection string, the backup method, the WAL archiving method and the retention policy. The retention policy should reflect the recovery requirements agreed with the business owner, and the team should document the choice. Verification: the configuration file parses without errors when Barman reads it, and the server name appears in the list of configured servers.

  5. Enable WAL archiving or streaming

    The database administrator sets the PostgreSQL parameters required for continuous archiving, either by configuring archive_command or by enabling streaming replication slots through Barman's streaming WAL receiver, depending on the design chosen. Changes that require a restart are scheduled with the owning team, since PostgreSQL applies some settings only after restart. Review the PostgreSQL continuous archiving documentation for the parameters on your version. Verification: a checked SQL query shows the expected archive_mode and archive_command or wal_level values, and a test switch of the WAL segment produces a new file in the Barman WAL archive or stream.

  6. Run the first base backup

    The Barman administrator triggers the initial base backup for the server, which copies the data directory from the PostgreSQL instance to the Barman backup catalog. Expect this first backup to be the largest and slowest; the duration depends on database size, network throughput and storage speed, so measure it in your own environment rather than planning from another system's figures. Keep the backup and WAL activity monitored while it runs. Verification: the backup list command shows a backup with status done, and its size and start and end times are recorded in the catalog.

  7. Verify readiness with the barman check command

    The administrator runs the barman check command against the server, which tests the connection, the replication settings, the archiving path, the backup method and the minimum redundancy requirements in one pass. Any failed line should be fixed and the check repeated until every item passes. Save the output with the change record, since it documents the initial state of the server. Verification: barman check returns OK for each check item for the server, and a further WAL switch on the database results in the new WAL file appearing in the Barman archive as expected.

How Barman restores to a point in time

Point-in-time recovery rebuilds a PostgreSQL cluster from a base backup plus the archived WAL files that follow it, replaying changes until the database reaches a chosen moment. With Barman, the restore is driven by barman recover, which copies the chosen base backup to the destination host and writes the recovery settings for you. The decisions that matter are the target, the timeline and the recovery target. The target can be a timestamp, a named restore point, a transaction ID or the end of available WAL. Set it explicitly with options such as --target-time rather than replaying everything by default, and record the value in the restore ticket. Choose the timeline deliberately too: after a failover or a previous point-in-time restore, the server may have forked onto a new timeline, and a recovery that ignores it can stop at the wrong branch or never reach the target. Confirm with your team which timeline should be followed and whether the target should be inclusive or exclusive.

Treat the restore path as a separate exercise that must be rehearsed on a host other than the production server. Run barman recover to a scratch directory or spare machine, start the instance, confirm it reaches the intended point and check the data against a known transaction. Each rehearsal should record the time from the decision to restore until the database accepts queries, along with the time spent copying the backup, fetching WAL and replaying it. Compare those figures with your recovery time objective and recovery point objective, and repeat the test after changes to backup size, WAL volume or network paths, because replay speed often grows with the amount of WAL since the last base backup. Ask your team which owner signs off on the measured result and where the timings are stored for later review.

Securing the Barman server and its backup copies

A Barman server holds a complete copy of every protected database, so it becomes one of the most sensitive systems in the estate. The considerations below cover who can reach it, how it authenticates to PostgreSQL and to other hosts, how copies are protected in transit and at rest, and how it is isolated from the hosts it protects.

Restrict access to the backup server

Treat the Barman host as a tier-zero system. Limit interactive logins to a small named group, route administration through a bastion or jump host with logging, and remove general-purpose packages and services. Confirm who can read the backup catalog, the barman.conf file and the barman system user's home directory, since these expose the layout of every backup. Review that list on a schedule, not only at build time.

Least-privilege PostgreSQL roles for backups

Barman connects to each database with a dedicated role instead of a superuser. Streaming backups need a role with replication privileges, and the connection rules in pg_hba.conf should allow only the Barman host, the replication or database name it needs, and a strong authentication method such as SCRAM. Check that the role cannot modify data, and document which database objects it can read during a backup. The PostgreSQL authentication methods documentation covers the options.

Authentication methods docs

SSH trust between hosts

Rsync-based backups and some recovery paths use SSH from the Barman server to each database host, and the reverse for restores. Use dedicated keys for the barman account, restrict each key to the required command or host with forced commands and source address limits where your SSH setup supports them, and store private keys with restricted file permissions. Rotate keys when staff change roles, and record which hosts trust which key.

Encrypt backups in transit and at rest

Streaming connections and WAL transfers should use TLS, and the server certificates should be validated by the Barman host rather than accepted blindly. For storage, decide whether encryption happens at the file system or volume level, in the object storage service, or in the backup tool itself, then confirm who holds the keys. Ask your team which of these the chosen Barman release and storage layer support before you commit to a design.

Separate credentials for object storage

When barman-cloud writes to object storage, give the backup host credentials that can write new objects but cannot delete or overwrite existing ones. Keep those credentials separate from the database hosts, so a compromised database server cannot erase its own history. Pair this with bucket versioning or object lock where the provider offers it, and confirm the retention behavior of your provider before relying on it.

Isolate the backup server from protected hosts

A ransomware event that reaches a database host should not be able to reach the backup server with the same credentials. Avoid shared passwords, shared SSH keys and shared directory services accounts between the two tiers, and place the Barman host in a separate network zone with inbound rules that allow only the backup traffic it needs. Keep one copy of backup data off the protected network, and test that a database host cannot log in to the Barman server.

What teams ask before running Barman themselves or hiring help

What does a Barman implementation cost and what drives the effort?

The cost depends on the number of PostgreSQL instances, how many sites and storage targets the backups reach, the recovery point and recovery time targets, and how much of the surrounding work is included. Barman itself is open source, so the cost is labor and infrastructure: the backup server, its disks or object storage, network capacity between sites, and the people who design, build, test and operate the setup. Effort rises with the number of clusters, with stricter retention and encryption requirements, and with off-site or immutable copies. Ask any partner for a written scope that lists the instances covered, the storage targets, the restore tests included and the handover items, then compare quotes against that same list.

How long does a first Barman setup take?

Duration depends on the number of instances, whether backups use streaming or rsync, whether copies go to object storage through barman-cloud, and how long the first restore test takes to prove. A small set of instances in an environment with existing storage and access paths is much quicker to bring online than a multi-site estate that needs new network rules, new buckets and approvals. No fixed timeline applies to every environment, so ask for a schedule with milestones for design, the first base backup, WAL archiving checks, a point-in-time recovery test and the handover, and confirm which of those the quote includes.

What must our team provide before the work starts?

Plan to provide the inventory of PostgreSQL instances and their versions, the recovery point and recovery time targets for each, the network paths between the database hosts and the backup server, and the storage you intend to use, whether that is local disk, a repository host or an object storage bucket. You will also need SSH or replication accounts with the privileges Barman requires, a decision on where credentials are kept, the retention periods your policy sets, and a named owner for approvals. Without these, the design stays provisional and the restore test cannot be scheduled against real targets.

Can an internal team run Barman without outside help?

Yes, an experienced PostgreSQL team can install and operate Barman alone, and many do. The questions to answer honestly are whether you have people who understand WAL archiving, replication slots, base backup timing and point-in-time recovery, whether someone checks backup status daily, and whether restore tests happen on a schedule rather than only during incidents. A partner is most useful for the first design, the first documented restore, and a runbook your on-call staff can follow at night. Ask a partner to show which parts of the work they would hand over and which they would keep.

How does Barman compare with pgBackRest and WAL-G in day-to-day operations?

All three tools take physical backups and archive WAL, so the choice usually comes down to operating model. Barman is built around a central backup server that manages many instances, supports streaming replication and rsync backups, and can send copies to object storage through barman-cloud. pgBackRest uses its own repository format and has strong parallelism and retention controls. WAL-G focuses on pushing base backups and WAL to cloud object storage with delta backups. Check which tool matches your storage layout, how your team already monitors backups, and whether your restore drills can exercise each tool. Sibling pages on pgBackRest and WAL-G go deeper on those trade-offs.

What recurring work does a Barman setup need after go-live?

Recurring work includes watching backup and WAL archiving status, reviewing failed jobs and alerts, managing retention and storage growth, rotating credentials, and applying Barman and PostgreSQL minor updates. Minor PostgreSQL releases do not change the storage format, so applying them means replacing executables and restarting, but they still need a change window. Major version upgrades require a separate plan, because backups must match the new cluster layout. Ask any partner which of these they operate under a retainer and which stay with your team, and confirm how often the restore tests repeat.

How are restore drills scheduled and what should they prove?

A restore drill should run on a fixed schedule, with a named owner, a target environment separate from production, and a recorded result. Each drill should restore a base backup, replay archived WAL to a chosen point in time, start the instance, and check data against a known marker. Record how long the restore took against your recovery time target and keep the logs as evidence for internal reviewers and auditors. Frequency is a policy decision for your organization, so set it against your recovery objectives and change control. Ask any partner to show a sample drill report and the exact steps they would run.

How DeployOpen scopes and delivers a Barman backup setup

Every DeployOpen Barman engagement starts with a written scope that names the PostgreSQL instances to be protected, the Barman server host, the backup method for each instance (streaming or rsync), the object storage target if barman-cloud is used, the recovery point and recovery time targets the client has set, and the retention rules. Deliverables and timelines are agreed in that document before any configuration begins, so the client knows what is included and can compare the quote against its own team's effort. Most engagements are fixed-scope. Ask for the scope to list each instance by name and to state which restore scenarios will be tested, because a scope that only says "configure backups" leaves the restore test undefined.

Configuration happens inside the client's own infrastructure, on their servers, their network and their storage accounts. DeployOpen works with the client's credentials, keeps the barman.conf settings, server definitions, WAL archive paths, cron or systemd schedules and access rules in the client's repository, and documents each choice so the operations team can run the setup after handover. The restore tests are the part to insist on. The deliverable should include restores to a point in time on a separate host, timed against the recovery time target, with the output of barman check and barman list-backup and the restored database checked for expected data. Ask for that evidence to be kept in a form your auditors and on-call team can read.

DeployOpen can also offer retainers for ongoing support, scheduled restore drills, and updates to the Barman and PostgreSQL versions in use. Ask which of these are included, how often restore tests are repeated, and who responds to a failed backup alert. DeployOpen prepares systems, controls and evidence that a compliance assessment can review, such as configuration records, access settings and restore test results. It does not issue audit reports, attestations or certifications. Those come from independent auditors or certification bodies, so confirm early which evidence your assessor expects and whether the scope covers it.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.