Automated PostgreSQL backups to S3-compatible storage with configurable schedules
1.1K
This Docker image provides automated PostgreSQL database backups to any S3-compatible storage (AWS S3, Cloudflare R2, MinIO, etc.).
POSTGRES_HOST - PostgreSQL host addressPOSTGRES_USER - PostgreSQL userPOSTGRES_PASSWORD - PostgreSQL passwordPOSTGRES_DB - PostgreSQL database nameS3_BUCKET - S3 bucket nameS3_ACCESS_KEY - S3 access keyS3_SECRET_KEY - S3 secret keyS3_ENDPOINT - S3 endpoint URL (e.g., https://s3.amazonaws.com for AWS)CRON_SCHEDULE - Cron schedule for backups (default: "0 2 * * *" - 2 AM daily)S3_PROVIDER - S3 provider name (default: "AWS", other options: "Cloudflare", "Minio", etc.)version: '3.8'
services:
backup:
image: postgres-s3-backup
environment:
POSTGRES_HOST: db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: your_password
POSTGRES_DB: your_database
S3_BUCKET: your-bucket
S3_ACCESS_KEY: your_access_key
S3_SECRET_KEY: your_secret_key
S3_ENDPOINT: https://s3.amazonaws.com
CRON_SCHEDULE: "0 2 * * *" # Optional: runs at 2 AM daily
volumes:
- backup-data:/backups
volumes:
backup-data:
To use with Cloudflare R2, set the following environment variables:
environment:
# ... PostgreSQL settings ...
S3_BUCKET: your-r2-bucket
S3_ACCESS_KEY: your_r2_access_key
S3_SECRET_KEY: your_r2_secret_key
S3_ENDPOINT: https://xxx.r2.cloudflarestorage.com
S3_PROVIDER: Cloudflare
daily folder in your S3 bucketmonthly folderdocker build -t postgres-s3-backup .
The image has been tested with:
Other S3-compatible services (AWS S3, MinIO, etc.) should work as well by setting the appropriate endpoint and provider.
Content type
Image
Digest
sha256:cd7cfdec2…
Size
34.2 MB
Last updated
over 1 year ago
docker pull ligul/postgres-s3-backup