image to provide backup functionality for PostgreSQL 16 with S3 as backend
2.2K
A simple docker container that runs PostgreSQL backups.
This image has NO DEFAULTS and expects the user to fill in ALL environment variables.
It's behaviour is set to create a backup off all databases in a PostgreSQL instance, creating one file per database, with custom format (option '-Fc' for pg_dump). Also creates a backup of the globals.
Each filename will have the format YYYYMMDD.DB_NAME.dmp (example: 20240520.db_name.dmp)
The backups are then uploaded to an S3 backend using AWS cli. Depending on the day of the backup, it will be uploaded to a different folder on the S3 bucket (on this order):
Backups will be stored in s3://$AWS_BUCKET/$LAPSE/$CUR_HOSTNAME/postgresql/ (where LAPSE is "monthly", "weekly" or "daily")
docker pull irradiare/irradiare-pg-backups:latest
To build the image yourself do:
git clone https://github.com/irradiare/irradiare-pg-backups.git
cd irradiare-pg-backups
docker build -t irradiare-pg-backup . # this will build the image with the tag `irradiare-pg-backup`
The best way to run the container is to setup ALL environment variables on docker compose and run with:
docker compose up
CRON_SCHEDULE in CRON format, for example "45 3 * * *" to make the backup at 3h45 am every dayDEST_FOLDER the folder to which the backup should be done. Useful if you want to mount a volume to the containerPGPASSWORD the password for the postgres userPGPORT the port for the postgres instancePGUSER the user for the postgres instancePGHOST the hostname for the postgres instanceCUR_HOSTNAME the hostname of the machine running the container (can be obtained from machine itself, deopending on the shell and OS, but this allows for finer tweaking in case we want to move the backups container to another machine)AWS_BUCKET the name of the S3 bucket to which the backups will be uploadedAWS_ACCESS_KEY_ID the AWS access key idAWS_SECRET_ACCESS_KEY the AWS secret access keyAWS_REGION the AWS regionNote To avoid interpolation issues with the env variable ${CRON_SCHEDULE} you will need to provide the variable as a quoted string i.e ${CRON_SCHEDULE}='*/1 * * * *' or ${CRON_SCHEDULE}="*/1 * * * *"
Here is a docker-compose.yml example for docker composer:
This work is based on the work of kartoza/docker-pg-backup which provides a much broader set of options for PostgreSQL backups.
Content type
Image
Digest
sha256:1d894fdc7…
Size
180.8 MB
Last updated
over 2 years ago
docker pull irradiare/irradiare-pg-backups