Sidecar for encrypted, incremental Postgres, MySQL/MariaDB, & MongoDB backups with restic to S3.
2.2K
Sidecar image for encrypted, incremental database backups with restic to S3. Supports Postgres, MySQL/MariaDB, and MongoDB. Retention policy with daily, weekly, monthly, and yearly archives.
/backup/work.restic backup uploads incrementally to the configured S3 repository.restic forget enforces the retention policy; with --prune it reclaims space.restic init before the first backup.DB_TYPE (required): postgres | mysql | mariadb | mongoRESTIC_REPOSITORY (required): e.g. s3:s3.amazonaws.com/<bucket>/<path> or s3:http://minio:9000/bucket/pathRESTIC_PASSWORD or RESTIC_PASSWORD_FILE (required): restic repository passwordRESTIC_TAGS (optional): comma-separated tags, e.g. app,env=prodBACKUP_INTERVAL_SECONDS (optional): 0 = run once and exit; otherwise an interval in seconds (e.g. 86400 = 1 day)KEEP_DAILIES, KEEP_WEEKLIES, KEEP_MONTHLIES, KEEP_YEARLIES (optional): retention policy valuesAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGIONWEBHOOK_URL: if set, send a JSON POST after each run (success or failure)WEBHOOK_METHOD: HTTP method, default POSTWEBHOOK_AUTH_HEADER: optional header value for auth, e.g. Authorization: Bearer <token>WEBHOOK_EXTRA_HEADERS: comma-separated Key=Value pairs to include as headersWEBHOOK_TIMEOUT_SECONDS: request timeout in seconds (default 10)PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASEPG_DUMP_ALL (optional, true|false): dump all databases using pg_dumpallMYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE (optional; empty = all databases)MONGO_URI/MONGODB_URI, or provide separately: MONGO_HOST, MONGO_PORT, MONGO_USER, MONGO_PASSWORD, MONGO_AUTH_DBstart (loops according to BACKUP_INTERVAL_SECONDS)run-once: perform a single backup immediately and exitforget-prune: apply retention and pruneinit: manually initialize a new restic repository (not required; the script auto-inits on first run if needed)You can schedule backups via either an interval or cron:
CRON_SCHEDULE (preferred): a standard cron expression (e.g., 0 2 * * * for daily at 02:00). When set, the container runs crond in the foreground and executes entrypoint.sh run-once at the specified times. Logs are written to /backup/cron.log.BACKUP_INTERVAL_SECONDS: fallback interval-based scheduler. If CRON_SCHEDULE is set, the interval is ignored.TZ (optional, default UTC): timezone for cron evaluation and logs. Example Europe/Amsterdam.The container sends a JSON payload like this after each run:
{
"status": "success|failed",
"message": "Backup geslaagd / Backup mislukt (exitcode=..)",
"startedAt": "2025-08-21T12:00:00Z",
"finishedAt": "2025-08-21T12:03:12Z",
"durationSeconds": 192,
"repository": "s3:s3.amazonaws.com/bucket/path",
"dbType": "postgres|mysql|mariadb|mongo",
"host": "db-host-hint",
"tags": ["app", "env=dev"],
"snapshotId": "abcd1234", // present on success if available
"dataAddedBytes": 123456, // bytes uploaded for this backup
"totalBytesProcessed": 789012, // bytes scanned
"totalDurationSeconds": 190, // restic-reported duration
"filesNew": 10,
"filesChanged": 0,
"filesUnmodified": 0
}
See the included docker-compose.yml for examples with Postgres, MySQL/MariaDB, and MongoDB using this sidecar. Adjust buckets, credentials, and tags for your environment. To enable cron-based scheduling, set CRON_SCHEDULE, for example 0 2 * * * to run nightly at 02:00.
docker build -t breaking-backups:latest .
RESTIC_PASSWORD_FILE mounted from a secret for better security.--single-transaction for MySQL/MariaDB as configured).MIT
Content type
Image
Digest
sha256:01af08d8f…
Size
68.4 MB
Last updated
about 1 year ago
docker pull toontoet/breaking-backups