Skip to content

willificent/rclone_BASH_backup_script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rclone-backup — cron-safe, Docker-aware server backup orchestration using rclone and Backblaze B2 with automatic email-delivered logging

SYNOPSIS

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.

DESCRIPTION

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.

DEPENDENCIES

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

FILES

rclone-backup.sh          main backup script
rclone-backup.jobs       job definition file (pipe-delimited)
~/.config/rclone/rclone.conf
~/.msmtprc                SMTP configuration

JOB FILE FORMAT

Each non-comment line defines one backup job:

TYPE|LABEL|SOURCE|DESTINATION

Where TYPE is one of:

  • SYNC Direct rclone sync of a filesystem path.

  • SYNC_HOME Sync of a home directory with symlink exclusion.

  • COMPOSE Docker 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

DOCKER BEHAVIOR

For COMPOSE jobs:

  • Docker services are controlled via Compose project names, not container names.
  • Each docker-compose.yml must define a top-level name: field.
  • Backup sequence is strictly:
docker compose down
rclone sync
docker compose up -d

This avoids inconsistent snapshots of live databases and volume mounts.

LOGGING AND REPORTING

  • 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).

EXIT STATUS

  • 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.

DESIGN NOTES

  • Uses rclone sync, not copy, to surface deletions.
  • Assumes backups may be audited manually.
  • Avoids embedding credentials in scripts.
  • Optimized for unattended execution and post-mortem clarity.

SEE ALSO

  • rclone(1)
  • docker-compose(1)
  • cron(8)
  • `msmtp(1)'

About

BASH script for backing up data using rclone to Backblaze B2. The script is context aware to distinguish SYNC (static folders), DOCKER-COMPOSE containers (down -> backup -> up), and HOME folders (no symlinks).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages