Sub topic 15
When to Use pgBackRest, Barman, or WAL-G
Assume you understand PostgreSQL data directories, WAL archiving, pg_basebackup, and the basic point-in-time recovery procedure. This chapter focuses on choosing a backup tool rather than writing your own archive and restore scripts.
Why use a dedicated backup tool?
A manual setup can work:
archive_commandcopies WAL files.pg_basebackupcreates a base backup.restore_commandcopies files back during recovery.
However, production backups need more than these commands. You also need retention rules, checksums, encryption, remote storage, parallel transfers, backup metadata, monitoring, and regular restore tests. A dedicated tool coordinates these tasks and records enough information to make recovery repeatable.
The main choices are:
| Tool | Main strength | Good fit |
|---|---|---|
| pgBackRest | Full-featured backup management and parallel transfers | Teams wanting a structured, PostgreSQL-focused system |
| Barman | Centralized backup server and administration | Organizations managing many database servers |
| WAL-G | Fast cloud and object-storage workflows | Cloud deployments using S3-compatible storage |
All three can manage physical backups and archived WAL. They differ mainly in configuration style, storage model, administration, and operational tooling.
pgBackRest
pgBackRest uses a repository called a stanza. A stanza describes one PostgreSQL cluster and its backup repository. It supports full, differential, and incremental backups, compression, encryption, parallel jobs, retention, and repository verification.
A minimal configuration might look like this:
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
repo1-compress-type=zstd
repo1-process-max=4
[main]
pg1-path=/var/lib/postgresql/16/mainAfter creating the stanza, an administrator can check the configuration and make a backup:
pgbackrest --stanza=main stanza-create
pgbackrest --stanza=main check
pgbackrest --stanza=main --type=full backuppgBackRest is often the best default for a single team that wants strong backup features without building a separate backup service.
Barman
Barman, short for Backup and Recovery Manager, normally runs on a dedicated backup host. It connects to PostgreSQL using streaming replication for WAL and pg_basebackup or streaming for base backups. This separates backup administration from the database server.
Barman is useful when one operations team manages many PostgreSQL instances. It provides commands for backup lists, retention, WAL checks, recovery preparation, and catalog inspection. Its centralized design can simplify access control and reporting, but it adds another server and service to maintain.
WAL-G
WAL-G is designed around fast transfers to remote object storage such as Amazon S3, Azure Blob Storage, Google Cloud Storage, or compatible systems. It uses environment variables for credentials and repository settings, so secrets should come from a secret manager or protected service environment.
Typical commands resemble these:
export WALG_S3_PREFIX=s3://example-pg-backups/main
export AWS_REGION=us-east-1
wal-g backup-push /var/lib/postgresql/16/main
wal-g backup-list
wal-g backup-fetch /restore/main LATESTWAL-G works well in cloud-native environments, especially when storage durability and geographic replication come from the object-storage platform. You must still configure credentials, lifecycle policies, encryption, monitoring, and restore tests.
Choosing a tool
Use these criteria:
- Choose pgBackRest for feature-rich, PostgreSQL-specific backup management.
- Choose Barman when a central backup host must manage many database servers.
- Choose WAL-G when object storage and cloud deployment are central to the design.
- Prefer the tool already supported by your operations team.
- Confirm that the tool supports your required PostgreSQL version, storage, encryption, and recovery targets.
- Test the complete path: base backup, WAL retrieval, recovery target, and application startup.
Exercise
A team has one PostgreSQL cluster, an S3-compatible repository, and wants parallel backups, encryption, and retention management. Which tool is a reasonable first choice, and what must the team verify before adopting it?
Show answer
pgBackRest is a reasonable first choice because it provides parallel transfers, encryption, and retention management. The team must verify compatibility with its PostgreSQL version and storage, configure credentials securely, monitor WAL and backup failures, and perform a complete test restore.