pgBackRest
Use pgBackRest for MainSDK backups of self-hosted Postgres - WAL archiving, point-in-time restore, RPO and RTO checks and restore drills. Planned.
pgBackRest is an open-source backup and restore tool for Postgres you run yourself, and a planned driver behind backup. It takes full, differential and incremental backups and archives the write-ahead log, which gives point-in-time restore. Pick it when you run Postgres on your own servers rather than a managed service.
Interfaces it serves
Pick pgBackRest in main.yaml for any of these. Your calls stay the same, and you can swap later.
backupBuilding for 1.2Driver pgbackrest pgBackRestPlanned driver
backup:
driver: pgbackrestBefore you start
- Install pgBackRest on your database hosts and configure a repository, on a backup server or in object storage, in the same region as the data.
- Turn on WAL archiving to the repository, schedule full and incremental backups, and set retention.
- Turn on repository encryption, and keep a second repository off-site if your policy calls for it.
Configure
backup:
rpo: 15m
rto: 1h
keep: 35d
drill: { every: 30d, to: scratch }How you select pgBackRest as the backup driver, and how MainSDK reaches its repository, are not specified yet.
Use it
import { runDrill } from "mainsdk/backup";
const result = await runDrill({ driver, declared, app: "my-app", at: new Date(), to: "scratch" }); // restores into scratch, never productionLocal development and testing
The drill is your test: run npx mainsdk drill restore --to scratch on a schedule in CI once the driver exists.
What MainSDK adds on top
- A check that your backup and retention settings can meet your RPO and RTO.
- Timed restore drills into scratch, signed as evidence. MainSDK never runs or stores backups itself.
See Backups and restore drills.
Limits and notes
- Planned driver, not in the spec yet; the backup-restore-evidence spec itself is phase 3, milestone 1.2.
- Keep each region's repository in that region: US, EU or India.
Swap to or from it
db:
driver: neon # was self-hosted postgres; point-in-time recovery comes from NeonFAQ
Can I use pgBackRest today? You can run it on your own Postgres, but MainSDK does not read its settings or drill it until the driver lands.
Next
Open questions
Was this page helpful?