dockerbackup
Backup container for systems that need to have the database and file system backed up
100K+
A minimal Alpine-based container to back up directories and databases on a schedule, with notification support via Nextcloud Talk Bot and e-mail.
tar.gz).sql.gz)| Variable | Description | Required |
|---|---|---|
FILES_TO_BACKUP | Space-separated list of folders to back up | โ |
BACKUP_DIR | Root folder for all backups | โ |
LOG_DIR | Log file location | โ |
RETENTION_DAYS | Days to keep old backups | โ |
CRON_SCHEDULE | Cron format (e.g. 0 * * * *) | โ |
STACK_NAME | Logical stack name (for identification) | โ |
BACKUP_NAME | Friendly container/service name | โ |
Set DB_TYPE=postgres, mariadb, mysql, or none
| Variable | Description |
|---|---|
POSTGRES_HOST | Database host |
POSTGRES_PORT | Database port (Standard port 5432 is already set) |
POSTGRES_USER | Username |
POSTGRES_PASSWORD | Password |
POSTGRES_DATABASE | DB name |
POSTGRES_EXTRA_OPTS | Extra options |
| Variable | Description |
|---|---|
MARIADB_HOST | Database host |
MARIADB_PORT | Database port (Standard port 3306 is already set) |
MARIADB_USER | Username |
MARIADBYSQL_PASSWORD | Password |
MARIADB_DATABASE | DB name |
MARIADB_EXTRA_OPTS | Extra options |
| Variable | Description |
|---|---|
MYSQL_HOST | Database host |
MYSQL_PORT | Database port (Standard port 3306 is already set) |
MYSQL_USER | Username |
MYSQL_PASSWORD | Password |
MYSQL_DATABASE | DB name |
MYSQL_EXTRA_OPTS | Extra options |
| Variable | Description |
|---|---|
NC_TALK_NOTIFY=on | Enable Talk Bot notifications |
NC_TALK_URL | Nextcloud base URL |
NC_TALK_BOT_CHANNEL | Bot ID or room token (from Talk or occ) |
NC_TALK_BOT_SECRET | Shared secret (from php occ talk:bot:install) |
| Variable | Description |
|---|---|
EMAIL_NOTIFY=on | Enable e-mail alerts |
EMAIL_TO | Recipient |
EMAIL_FROM | Sender |
SMTP_SERVER | SMTP hostname/IP |
SMTP_PORT | Port (default: 587) |
SMTP_USER | SMTP user (if auth needed) |
SMTP_PASS | SMTP password |
SMTP_TLS=on | Enable STARTTLS (default: on) |
๐ฆ Uses
msmtp(included) for sending mail
docker-compose.ymlversion: '3'
services:
backup:
build: .
environment:
FILES_TO_BACKUP: "/data"
BACKUP_DIR: "/backup"
LOG_DIR: "/log"
RETENTION_DAYS: 30
CRON_SCHEDULE: "0 * * * *"
BACKUP_NAME: "web-backup-db"
DB_TYPE: "postgres"
POSTGRES_HOST: "postgres"
POSTGRES_USER: "backupuser"
POSTGRES_PASSWORD: "secret"
POSTGRES_DATABASE: "myapp"
NC_TALK_NOTIFY: "off"
NC_TALK_URL: "https://cloud.example.com"
NC_TALK_BOT_CHANNEL: "abc123"
NC_TALK_BOT_SECRET: "your_shared_hmac_secret"
EMAIL_NOTIFY: "off"
EMAIL_TO: "[email protected]"
EMAIL_FROM: "[email protected]"
SMTP_SERVER: "smtp.example.com"
SMTP_PORT: 587
SMTP_USER: "smtp-user"
SMTP_PASS: "smtp-pass"
SMTP_TLS: "on"
volumes:
- ./data:/data
- ./backup:/backup
- ./log:/log
/backup/
2025-04/
files_data_2025-04-30_1400.tar.gz
postgres_myapp_2025-04-30_1400.sql.gz
/log/
backup_2025-04-30.log
Backups older than RETENTION_DAYS are removed automatically. Log entries show deleted files.
Add this to your Compose file to track success:
healthcheck:
test: ["CMD", "/scripts/healthcheck.sh"]
interval: 5m
timeout: 10s
retries: 3
start_period: 30s
The backup script writes this file only on success
MIT License โ free for commercial and private use.
Content type
Image
Digest
sha256:18ca488c4โฆ
Size
26.1 MB
Last updated
9 months ago
docker pull onesystems/dockerbackup