A docker image that is scheduled to backup a postgres database and upload the dump file to an S3 bucket.
https://hub.docker.com/repository/docker/thomaslule/postgres-s3-backup
Docker-compose usage example:
version: "3"
services:
postgres:
image: postgres:12.2-alpine
environment:
POSTGRES_PASSWORD: admin
PGDATA: /data/postgres
volumes:
- postgres_data:/data/postgres
postgres-backup:
image: thomaslule/postgres-s3-backup:latest-postgres12
depends_on:
- postgres
environment:
S3BACKUP_DB_CONNECTION_STRING: postgresql://postgres:admin@postgres:5432/postgres
S3BACKUP_CRON_SCHEDULE: "0 5 * * 0"
S3BACKUP_S3_REGION: eu-west-3
S3BACKUP_S3_BUCKET: db-backup
AWS_ACCESS_KEY_ID: yourkey
AWS_SECRET_ACCESS_KEY: yoursecret
volumes:
postgres_data:
The connection string for your postgres database.
- required: false
- default:
postgresql://postgres:admin@localhost:5432/postgres
The CRON expression that describes when the export must be done.
- required: false
- default:
0 5 * * 0
(every sunday at 05:00)
The AWS region where the bucket lives
- required: true
The AWS S3 bucket name
- required: true
The AWS Access Key
- required: true
The AWS Secret Key
- required: true
List of published tags here.
You must chose the image that corresponds to your postgres version, or you will get an error aborting because of server version mismatch
. This is because this tool uses pg_dump
and it only works for a server with the same version.
If you want to build your own image for another version, you can look for an alpine branch that contain the right postgres version here.