Hacker News new | past | comments | ask | show | jobs | submit
pg-restic – Postgres backups to S3/B2 (or any S3-compatible storage) using restic, in one small Docker container.

https://github.com/isriram/pg-restic

I needed Postgres backups at work and at home at the same time. I tried a few existing images, but after spending time setting them up I found they shipped an older pg_dump that couldn't back up newer Postgres versions. So I built my own.

It runs pg_dumpall on a cron schedule and streams it straight into a restic repo, so nothing touches local disk. You get encrypted, deduplicated snapshots (hourly dumps of a mostly unchanged DB take very little extra space), retention policies, and daily pruning. If the dump fails, no snapshot is saved. It ships pg_dumpall 18, so it can back up anything from 9.2 to 18.

I now run it in production at work, so I'll be keeping it up to date. I'm no expert, and this is the first time I'm doing something like this (putting something out there), so any feedback is welcome, especially from the database pros.

It's not fancy, but it's something I needed, and boy, I really needed something like this.

I love restic and this project is a truly great application of it! Nicely done!
This is great! Thanks for releasing it. Can I back up my PG to restic's rest server?
Thank you! I honestly wasn't even aware of rest-server. However, I just tested it against rest-server and it works.

Set RESTIC_REPOSITORY=rest:http://your-server:8000/your-repo, put your credentials in RESTIC_REST_USERNAME/RESTIC_REST_PASSWORD (or in the URL), and leave out the AWS variables.

So rest-server seems to have an --append-only mode. If that's enabled, backups still succeed, but the retention step is refused, so each run reports an error and old snapshots are never removed.