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
barmancommand line - A bundled local PostgreSQL 16 instance configured as a demo backup source, listening on the loopback interface only
backup_method = postgresstreaming 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 drivespg_basebackupover a streaming replication connection, so there are no ssh keys and noarchive_commandto manage. WAL streams continuously into the catalogue throughpg_receivewalagainst 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.1only, 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) andstreaming_barman(replication) roles each receive an independent random password. The image writes those passwords to the barman user's~/.pgpass(/var/lib/barman/.pgpass, mode0600), so Barman authenticates automatically. A root-only summary goes to/root/barman-credentials.txt. - Per-VM PostgreSQL credentials stored in the barman user's
~/.pgpassand 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.
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.
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 1001First 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.txtConfirm 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 pgList 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 pgInspect 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 latestTake 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 pgRestore 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-demoBarman 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.
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 7Create 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 myserverScheduled 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/barmanSecurity 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/barmancontains 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.
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
Overview
Barman (Backup and Recovery Manager) is the open-source disaster-recovery manager for PostgreSQL from EnterpriseDB. It manages base backups and continuous write-ahead-log (WAL) archiving for one or more PostgreSQL servers, and it performs point-in-time recovery. You can restore a database to any moment inside your retention window.
This SecureAnyCloud image ships Barman 3.19.1 with a bundled PostgreSQL 16 source, both from the official PostgreSQL PGDG package repository. They are wired together as a fully working demonstration, so a real base backup is taken and verified the moment your instance boots.
What you get:
- A headless image. There is no web interface. You operate it over SSH as the
barmansystem user. - A bundled PostgreSQL source that binds to loopback only on
127.0.0.1:5432and is never exposed to the network - A streaming replication connection with a named replication slot, so no WAL is lost, and physical base backups taken with
pg_basebackup - Fresh, strong passwords for the PostgreSQL, Barman and replication roles, unique to your instance. On first boot, a one-shot service generates them, writes them only to the Barman user's protected
~/.pgpass, creates the replication slot, takes the first base backup, and confirms the backup source is healthy before completing. No shared or default database credentials ship in the image. - The entire Barman catalogue, every base backup and every streamed WAL segment, on a dedicated, independently resizable EBS data volume mounted at
/var/lib/barman. You can grow, snapshot and back up that volume independently of the operating system disk. - 24/7 SecureAnyCloud support
SecureAnyCloud is not affiliated with or endorsed by EnterpriseDB. Barman is a project of EnterpriseDB Corporation.
Prerequisites
Before you deploy this image, you need:
- An Amazon Web Services account where you can launch EC2 instances
- IAM permissions to launch instances, create security groups, and subscribe to AWS Marketplace products
- An EC2 key pair in the target Region for SSH access to the instance
- A VPC and subnet in the target Region, with a security group that allows inbound port 22 from your management network
- The AWS CLI (version 2) installed locally, if you plan to deploy from the command line
Recommended instance type: m5.large (2 vCPU, 8 GB RAM) or larger. Barman benefits from additional memory and I/O headroom as the number of protected servers and the size of the catalogue grow.
Launch the Instance from the AWS Marketplace
Sign in to the AWS Management Console, open the EC2 service, and select Launch instance. Under Application and OS Images, choose AWS Marketplace AMIs and search for Barman. Select the SecureAnyCloud listing, choose Select, then choose Continue on the subscription summary.
Pick an instance type of m5.large or larger. Choose your EC2 key pair under Key pair (login). Under Network settings, select your VPC and subnet, and create or select a security group that allows inbound port 22 from your management network. The image attaches the dedicated Barman catalogue volume automatically.
Select Launch instance. First-boot initialisation runs once, after the instance state becomes Running and the status checks pass. It brings up PostgreSQL, rotates the per-instance passwords, creates the replication slot, takes the first base backup and verifies backup health. This takes a minute or two.
Launch the Instance from the AWS CLI
The command below launches an instance from the SecureAnyCloud Barman Marketplace AMI into an existing subnet and security group. Make these replacements first:
- Replace <ami-id> with the AMI ID shown on the Marketplace listing.
- Replace <key-name> with your EC2 key pair name.
- Replace <sub-id> with your subnet ID.
- Replace <security-group-id> with a security group that opens port 22 from your management network.
aws ec2 run-instances \
--image-id <ami-id> \
--instance-type m5.large \
--key-name <key-name> \
--subnet-id <sub-id> \
--security-group-ids <security-group-id> \
--metadata-options HttpTokens=required \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=barman}]'When the instance reaches the Running state and its status checks pass, note its public IP address or DNS name from the EC2 console or with aws ec2 describe-instances.
Connect to Your Instance
Connect over SSH using your key pair and the login user for your operating system variant. For Ubuntu 24.04, the login user is ubuntu.
ssh -i <key-name>.pem ubuntu@<public-ip>The message of the day summarises the key Barman commands. Run everyday Barman commands as the barman system user, via sudo -u barman.
Confirm the Backup Source Is Healthy
Barman's check command verifies every part of the backup pipeline for a server: the PostgreSQL connection, backup privileges, streaming replication, the WAL level, the replication slot, WAL streaming (receive-wal), the archiver, and the retention policy. On this image, the bundled server is named pg.
systemctl is-active postgresql@16-main.service
sudo -u barman barman check pgEvery line should report OK. This confirms that the backup source and WAL streaming are healthy.
List and Inspect Backups
The image takes a base backup automatically on first boot. List the catalogue and inspect the most recent backup. The catalogue lives on the dedicated EBS volume mounted at /var/lib/barman.
sudo -u barman barman list-backup pg
sudo -u barman barman show-backup pg latestshow-backup reports the backup status (DONE), the backup method (postgres, meaning a streaming pg_basebackup), the PostgreSQL version, and the estimated size.
Take a Backup on Demand
You can take a base backup at any time. A scheduled base backup also runs daily at 01:30 by cron, and barman cron maintains WAL streaming every minute.
sudo -u barman barman switch-wal --force --archive pg
sudo -u barman barman backup pg --wait sudo -u barman barman list-backup pgPoint-in-Time Recovery
barman recover restores a chosen backup, plus the WAL needed to reach a target time, into a target directory. The result is a ready-to-start PostgreSQL data directory. The example restores the latest backup into /var/tmp/restore.
sudo rm -rf /var/tmp/restore
sudo install -d -o barman -g barman /var/tmp/restore
sudo -u barman barman recover pg latest /var/tmp/restore
sudo ls /var/tmp/restoreTo recover to a specific moment instead of the latest state, add --target-time "YYYY-MM-DD HH:MM:SS".
On Debian and Ubuntu, the PostgreSQL configuration files live under /etc/postgresql/16/main. Copy them alongside the recovered data directory, or supply a config_file, before you start the recovered cluster.
The Backup Catalogue Volume
The Barman catalogue is stored on a dedicated EBS volume, separate from the operating system disk, so your backups are isolated, easy to snapshot off-instance, and simple to resize.
df -h /var/lib/barman findmnt /var/lib/barmanThe mount is defined by filesystem UUID in /etc/fstab, so it re-attaches automatically on every boot. Use Amazon EBS Snapshots to copy the catalogue off-instance. To increase capacity, grow the volume in the EC2 console and extend the filesystem.
Back Up Your Own PostgreSQL Servers
The bundled pg server is a working demonstration. To protect your production databases, take these steps:
- Add a Barman server configuration under
/etc/barman.d/that points at your PostgreSQL host. - Grant Barman a replication connection on that host.
- Open network reachability from this instance to your database, with a security group rule for the PostgreSQL port (typically 5432) on the private network.
Barman can manage many servers from this one host, each with its own retention policy. See the official Barman documentation for the streaming and rsync/SSH backup methods and for multi-server topologies.
Support
SecureAnyCloud provides 24/7 technical support for this image by email and live chat. Our engineers assist with deployment, Barman configuration, multi-server setup, WAL archiving and streaming, retention policy design, and point-in-time recovery.
Contact sales@secureanycloud.com with your instance ID, Region and a description of your question. For refund requests, email the same address with your AWS Marketplace subscription details.
All product and company names are trademarks or registered trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
Deploy on AWS
Launch Barman for PostgreSQL on AWS with 24/7 support from SecureAnyCloud.
View on Marketplace
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com