Deployment guide

Barman

Overview

Barman (Backup and Recovery Manager) is the open-source disaster recovery manager for PostgreSQL from EnterpriseDB. It takes scheduled physical base backups, continuously streams the write-ahead log so you can recover to any point in time, enforces retention policies, and drives full restores, all from a single command-line catalogue.

This SecureAnyCloud image runs Barman on Ubuntu 24.04 on Azure. It also installs a local PostgreSQL 16 instance from the official PostgreSQL PGDG repository and configures it as a fully working demo backup source. On first boot, Barman wires itself to that PostgreSQL, takes a first base backup and starts streaming WAL. You see a real backup catalogue immediately, and then point Barman at your own production PostgreSQL servers.

What you get:

  • Barman (Backup and Recovery Manager) from the PostgreSQL PGDG repository, driven by the barman command line
  • A bundled local PostgreSQL 16 instance configured as a demo backup source, listening on the loopback interface only
  • backup_method = postgres streaming base backups, plus continuous WAL streaming into the catalogue through a replication slot
  • Streaming backup topology, the most robust choice for a single VM. Barman uses backup_method = postgres, which drives pg_basebackup over a streaming replication connection, so there are no ssh keys and no archive_command to manage. WAL streams continuously into the catalogue through pg_receivewal against a named replication slot, which guarantees PostgreSQL keeps every WAL segment until Barman has safely received it.
  • Scheduled backups by cron: WAL streaming maintenance every minute and a base backup daily at 01:30
  • Loopback only, no public database port. The bundled PostgreSQL listens on 127.0.0.1 only, and Barman reaches it entirely over the loopback interface. The image opens only TCP 22 in its Network Security Group, so there is no public database port to attack.
  • No baked credential. On first boot, the PostgreSQL superuser and the barman (management) and streaming_barman (replication) roles each receive an independent random password. The image writes those passwords to the barman user's ~/.pgpass (/var/lib/barman/.pgpass, mode 0600), so Barman authenticates automatically. A root-only summary goes to /root/barman-credentials.txt.
  • Per-VM PostgreSQL credentials stored in the barman user's ~/.pgpass and summarised in a root-only file, never baked into the image
  • A clean cluster on every VM: the PostgreSQL data directory is reset when the image is built, so every deployed VM starts with fresh credentials
  • A first base backup taken automatically on first boot, so the catalogue is populated immediately
  • Unattended security upgrades left enabled, so the appliance keeps receiving patches
  • 24/7 SecureAnyCloud support

Prerequisites

  • An active Azure subscription, an SSH public key, and a VNet with a subnet in the target region
  • A subscription to the Barman listing on Azure Marketplace
  • A Network Security Group rule allowing TCP 22 (admin) from your management network. This appliance exposes no database port.

Recommended virtual machine size: Standard_B2s (2 vCPU, 4 GB RAM) for the demo and light backup workloads. To protect larger production databases, use Standard_D2s_v5 or larger, and attach a data disk sized for your backup retention.

1

Deploy from the Azure Portal

Search the Azure Marketplace for Barman, select the SecureAnyCloud publisher, and click Create.

Configure the Network Security Group to allow TCP 22 for administration from your management network. You need no inbound database port, because the bundled PostgreSQL is loopback only.

2

Deploy from the Azure CLI

RG="backup-prod"; LOCATION="eastus"; VM_NAME="barman1" IMAGE_URN="sac1647283583153:barman-ubuntu-24-04:default:latest" SSH_KEY="$(cat ~/.ssh/id_rsa.pub)" az group create --name "$RG" --location "$LOCATION"
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn sac1647283583153:barman-ubuntu-24-04:default:latest
az vm create \
  --resource-group "$RG" --name "$VM_NAME" \
  --image "$IMAGE_URN" \
  --size Standard_B2s \
  --admin-username azureuser \
  --ssh-key-values "$SSH_KEY" \
  --public-ip-sku Standard
# Open only the admin port on the VM's NSG:
az vm open-port --resource-group "$RG" --name "$VM_NAME" --port 22 --priority 1001
3

First boot

On first boot, the image does the following:

  • Starts PostgreSQL on the loopback interface
  • Generates a per-VM password for each database role
  • Writes the barman user's ~/.pgpass
  • Creates the replication slot and starts WAL streaming
  • Takes the first base backup
  • Writes /root/barman-credentials.txt

This completes within a minute. SSH in as azureuser and read the details:

sudo cat /root/barman-credentials.txt
4

Confirm the backup source and Barman are healthy

The bundled PostgreSQL is active. barman check pg verifies the whole backup chain end to end: the management and streaming connections, the WAL level, the replication slot, WAL streaming (receive-wal running), the pg_basebackup tooling, and the minimum redundancy policy. Every line must read OK.

systemctl is-active postgresql.service
sudo -u barman barman check pg
5

List the backup catalogue

barman list-backup shows every base backup Barman holds for the server. The image took the first backup automatically on first boot, and the daily cron job adds a new one at 01:30.

sudo -u barman barman list-backup pg
6

Inspect a backup

barman show-backup prints the full detail of a backup: the PostgreSQL version and system ID, the backup method, the size, the WAL range it spans, and the retention policy status.

sudo -u barman barman show-backup pg latest
7

Take a backup on demand

Backups run automatically on a schedule, and you can also take one at any time. Barman streams a fresh base backup from PostgreSQL and records it in the catalogue.

sudo -u barman barman backup pg
8

Restore a backup to a directory

Recovery is the other half of Barman. barman recover rebuilds a complete PostgreSQL data directory from a chosen backup plus the WAL needed to make it consistent.

The command below restores the latest backup into a scratch directory, to verify that recovery works end to end. It clears the target first, so you can repeat it.

sudo -u barman rm -rf /var/tmp/barman-restore-demo
sudo -u barman barman recover pg latest /var/tmp/barman-restore-demo

Barman prints a WARNING that postgresql.conf, pg_hba.conf and pg_ident.conf were not restored. This is expected on Ubuntu. PostgreSQL keeps its configuration under /etc/postgresql, outside the data directory, so it is not part of a physical backup.

Copy your own configuration into place before you start a recovered instance. The recovered data directory itself is complete and valid.

9

Protect your own PostgreSQL servers

The bundled PostgreSQL is a working demo. To back up your own PostgreSQL servers, add a Barman server definition under /etc/barman.d/ for each one. A streaming definition looks like this:

[myserver] description = "Production PostgreSQL" conninfo = host=db.example.internal user=barman dbname=postgres streaming_conninfo = host=db.example.internal user=streaming_barman dbname=postgres backup_method = postgres streaming_archiver = on slot_name = barman create_slot = auto retention_policy = REDUNDANCY 7

Create the matching barman and streaming_barman roles on the target PostgreSQL, add their passwords to /var/lib/barman/.pgpass, then verify and take a first backup:

sudo -u barman barman receive-wal --create-slot myserver
sudo -u barman barman cron
sudo -u barman barman check myserver
sudo -u barman barman backup myserver
10

Scheduled backups and WAL streaming

The appliance ships two cron jobs. barman cron runs every minute to keep WAL streaming alive and process the archive, and a base backup runs daily at 01:30. Review or adjust the schedule in /etc/cron.d/barman.

cat /etc/cron.d/barman
11

Security recommendations

  • Keep the database private. The bundled PostgreSQL is loopback only, and no database port is exposed. If you attach additional databases, reach them over a private VNet, never a public address.
  • Restrict the NSG. Allow TCP 22 only from your management network.
  • Protect the backup catalogue. Barman's catalogue under /var/lib/barman contains your data. Restrict access to the VM, and consider attaching an encrypted data disk sized for your retention policy.
  • Set a retention policy that matches your recovery objectives. The demo keeps two backups (retention_policy = REDUNDANCY 2), and production servers usually want more. Adjust the policy per server in /etc/barman.d/.
  • Test your restores. A backup you have never restored is not a backup. Use barman recover (Step 8) regularly to prove your recovery path.
  • Keep the OS and Barman patched. Unattended security upgrades remain enabled on the running VM.
12

Support and Licensing

Barman is developed by EnterpriseDB and distributed under the GPL 3.0 license. This SecureAnyCloud image bundles the unmodified PGDG Barman and PostgreSQL packages.

SecureAnyCloud provides the packaging, the secure-by-default loopback-only configuration, the streaming backup and WAL topology, the first-boot credential generation, and 24/7 support with a guaranteed 24-hour response SLA.

SecureAnyCloud is not affiliated with or endorsed by EnterpriseDB. Barman and PostgreSQL are marks of their respective owners and are used here only to identify the software.

Deploy on Azure

Find Barman on Ubuntu 24.04 LTS on the Azure Marketplace, published by SecureAnyCloud. Deploy from the Portal or the Azure CLI as shown above.

Need Help?

Email sales@secureanycloud.com for deployment help, configuration questions, or licensing enquiries.

Deploy on Azure

Launch Barman PostgreSQL Backup and Recovery Manager on Ubuntu 24.04 LTS on Azure with 24/7 support from SecureAnyCloud.

View this image

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com

Deploy on Azure