A docker image that is scheduled to backup a postgres database and send the export file to a mail address.
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-mail-backup:latest
depends_on:
- postgres
environment:
MAILBACKUP_DB_CONNECTION_STRING: postgresql://postgres:admin@postgres:5432/postgres
MAILBACKUP_CRON_SCHEDULE: "0 5 * * 0"
MAILBACKUP_SMTP_CONFIG: '{"host":"smtp.gmail.com","auth":{"user":"[email protected]","pass":"its password"}}'
MAILBACKUP_FROM_MAIL: [email protected]
MAILBACKUP_TO_MAIL: [email protected]
volumes:
postgres_data:
For a simple usage without any encryption from a gmail address, you'll have to enable "less secure apps" on the sender account: https://myaccount.google.com/lesssecureapps?pli=1
MAILBACKUP_DB_CONNECTION_STRINGThe connection string for your postgres database.
postgresql://postgres:admin@localhost:5432/postgresMAILBACKUP_CRON_SCHEDULEThe CRON expression that describes when the export must be done.
0 5 * * 0 (every sunday at 05:00)MAILBACKUP_SMTP_CONFIGA JSON-encoded string describing the SMTP configuration for NodeMailer. This will be passed as first argument of its createTransport function. See the doc here.
MAILBACKUP_FROM_MAILThe sender mail address.
MAILBACKUP_TO_MAILThe recipient mail address.
This docker image uses pg_dump and if its version isn't exactly the same as the postgres server version, this tool will fail with the error aborting because of server version mismatch.
In order to have the same pg_dump version as your database, you must rebuild this image from another alpine version, you can search an alpine branch that contain the right postgres version here.
Content type
Image
Digest
Size
21.7 MB
Last updated
over 6 years ago
docker pull thomaslule/postgres-mail-backup