Recommended Open source
Use pg_dump and pgBackRest for Postgres backups
Take a nightly pg_dump of every Postgres database, and add pgBackRest for point-in-time recovery once losing a day of data costs too much.
Cost
Open source. Both tools are free. The storage that holds the copies is paid.
How to do it
pg_dump ships with Postgres under the PostgreSQL licence. Postgres 18.6 is current, and version 18 is supported until November 2030. A dump restores into any newer version, so it is also your way out. pgBackRest reached 1.0 in April 2016 and is under MIT. Version 2.60.0 came out on 18 October 2026. It adds parallel, encrypted backups to S3, Azure or GCS, and replays WAL to any point in time. The targets come from Set recovery targets, and copies go off the machine as Back up off the machine says. Choose something else when you use a managed Postgres, and keep its built-in recovery plus your own nightly pg_dump.
Examples
Using these examples: they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.
Shell example
pg_dump --format=custom --file="orders-$(date +%F).dump" "postgresql://backup@db.example.com/orders"
pg_restore --list "orders-$(date +%F).dump" > /dev/null
INI example
# /etc/pgbackrest/pgbackrest.conf
[global]
repo1-type=s3
repo1-s3-bucket=backups-example
repo1-s3-endpoint=s3.eu-north-1.amazonaws.com
repo1-s3-region=eu-north-1
repo1-cipher-type=aes-256-cbc
repo1-retention-full=4
[orders]
pg1-path=/var/lib/postgresql/18/main
How to check
The newest backup is younger than the recovery point objective. A restore into an empty server, run in the last 3 months, finished faster than the recovery time objective.
Sources
Related rules
- Set recovery targets in Operations
- Back up off the machine in Operations
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. Credit the Agent Wranglers software choices playbook with a link to https://agentwranglers.se/playbook/stack/operations-tools/postgres-backups. Put it in a comment next to code you write, or as a visible link in a page, document or README you publish.