rclone-backup — cron-safe, Docker-aware server backup orchestration using rclone and Backblaze B2 with automatic email-delivered logging
rclone-backup.sh
Executed non-interactively (typically via cron) to perform structured backups of filesystem paths and Docker Compose–managed services, emitting per-job logs and a summary report via SMTP.
rclone-backup is a Bash-based backup orchestration system designed for self-hosted servers running Docker Compose workloads.
It coordinates:
- filesystem backups using
rclone sync - container quiescence (
docker compose down → backup → up) - structured job definitions via a human-readable config file
- post-run status reporting via SMTP
The system prioritizes correctness, inspectability, and failure visibility over abstraction or cleverness.
Required:
- bash (POSIX-compatible shell with arrays)
- rclone (recent version with Backblaze B2 support)
- docker
- docker compose (v2; Compose plugin)
- msmtp (send-only SMTP client)
- cron (or compatible scheduler)
Optional but assumed:
- Backblaze B2 account and bucket
- password manager (e.g.,
pass) for SMTP credentials - mail client capable of RFC-compliant message parsing
rclone-backup.sh main backup script
rclone-backup.jobs job definition file (pipe-delimited)
~/.config/rclone/rclone.conf
~/.msmtprc SMTP configuration
Each non-comment line defines one backup job:
TYPE|LABEL|SOURCE|DESTINATION
Where TYPE is one of:
-
SYNCDirectrclone syncof a filesystem path. -
SYNC_HOMESync of a home directory with symlink exclusion. -
COMPOSEDocker Compose–aware backup: containers are stopped, data is synced, containers are restarted.
Example:
SYNC|Media|/storage/media|b2:server/media
SYNC_HOME|Home|/home/william|b2:server/home
COMPOSE|Websites|/storage/williamsoutherland.com|b2:server/websites
For COMPOSE jobs:
- Docker services are controlled via Compose project names, not container names.
- Each
docker-compose.ymlmust define a top-levelname:field. - Backup sequence is strictly:
docker compose down
rclone sync
docker compose up -d
This avoids inconsistent snapshots of live databases and volume mounts.
- Each job emits its own rclone log file.
- Exit status and timing are captured per job.
- A summary report is assembled and sent via
msmtp. - Email formatting is RFC-compliant (explicit headers, single blank line).
0— all jobs completed successfully- non-zero — one or more jobs failed or aborted
Failures are reported via email; silent success is considered a bug.
- Uses
rclone sync, notcopy, to surface deletions. - Assumes backups may be audited manually.
- Avoids embedding credentials in scripts.
- Optimized for unattended execution and post-mortem clarity.
rclone(1)docker-compose(1)cron(8)- `msmtp(1)'