137 points · by thunderbong · 3y ago · 26 comments
[1] https://www.postgresql.org/docs/current/continuous-archiving...
I just had a quick skim of those docs, looks like lots of paragraphs going over all of all the things that can go wrong and how to prevent them. Good. If it takes a week to read all that and set up then it takes a week. I'll take a pass on the "docker container that just does it for me" thanks.
I just finished a setup where I run PostgreSQL as a quadlet on CoreOS, and in order to manage backups I use systemd Require so the postgres container depends on a pgbackrest container that just runs a relatively simple script to check if storage is empty or not, and restores the backup from S3 if storage is empty.
And another container runs as a oneshot timer that takes full and incremental backups to S3.
Instead of this [1] I use a much simpler while ! pg_isready loop.
1. https://gist.github.com/efrecon/86456960e2110b287632fd7f42c1...
An immutable OS like CoreOS for example isn't much different than a regular distro. You can still do a lot of manual work on it if you want. I try to avoid doing manual work on it because I want to be strict IaC, but I can for example test doing a major release upgrade in staging, manually over SSH, and work out the kinks, before I put it into practice using containers and scripts in production.
Though I see very little reason to automate the hell out of a major release upgrade, better do it safely and slowly with SOP's.
I use pg_isready. Unfortunately I won't link my project because I try to keep this HN account separate from my true identity.
It does everything, uses pg_dump under the hood, and adds the output as files for Borg.
Borg then takes care of encryption, incremental and also bit rot. Best solution ever in my book.
Also you can directly restore the db with Borgmatic.
https://torsion.org/borgmatic/docs/how-to/backup-your-databa...