About bugs you can avoid with the right transaction isolation level.
A managed RDS is not exactly cheap. And I like my pet projects to be cheap. That‘s how I ran into the problem of making scheduled backups of a Postgres DB. I can‘t be the only one, so here is one way of solving it with a docker image.
Within the running container this happens:
pg_dumpcreates a dump
aws-cliuploads the dump to s3
cronschedules a job with the two steps above to run every x minutes/houres/etc.
Pretty straight forward. But there is a catch.
pg_dump command may not work across Postgres versions. Meaning you would want the
pg_dump command to match the version of the Postgres database you pull a dump from.
Therefore building this image requires the build arg
Here is an example of how building the image could look like for Postgres v13.5:
docker build --build-arg "POSTGRES_IMAGE_TAG=13.5" -t pg_dump_s3 .
Internally it pulls the official Postgres image matching the provided tag. Here is a list of available tags for official Postgres images.
Note that this docker image does not work for all of them. E.g.
*-alpine images don‘t work. But there is at least one that does for every major version from v9 to v14. Have a look at this list of tested tags.
See the README for detailed information on how to build the image and run the container.
Feel free to open PRs or issues 🙂