Genericize backup documentation and defaults

This commit is contained in:
howard committed 2026-11-01 19:41:25 +13:00
1 parent 3d52a9af33
commit ac6823f840
5 files changed
+25 -21

No files matched your search

+4 -3
View File
@@ -11,15 +11,16 @@ PULL_IMAGES=1
START_TIMEOUT=90 START_TIMEOUT=90
WAIT_INTERVAL=3 WAIT_INTERVAL=3
START_RETRIES=1 START_RETRIES=1
LOCK_FILE="/run/lock/zorruno-docker-backup.lock" LOCK_FILE="/run/lock/docker-backup.lock"
ZSTD_EXTRA_OPTS="-T0 -12" ZSTD_EXTRA_OPTS="-T0 -12"
# Space-separated tar member paths relative to SOURCE_BASE_DIR. # Space-separated paths as they appear inside each project archive.
# Example: TAR_EXCLUDES="nextcloud/data otherproject/cache" # Example: TAR_EXCLUDES="nextcloud/data otherproject/cache"
TAR_EXCLUDES="" TAR_EXCLUDES=""
# Final backup-run reports retained locally for this many days. # Final backup-run reports retained locally for this many days.
BACKUP_HISTORY_DAYS=30 BACKUP_HISTORY_DAYS=30
# Set to 1 when BACKUP_ROOT must reside on encrypted storage (e.g. Beaver). # Optional: set to 1 when BACKUP_ROOT must reside on encrypted storage.
BACKUP_REQUIRE_ENCRYPTED_STORAGE=0 BACKUP_REQUIRE_ENCRYPTED_STORAGE=0
BACKUP_HISTORY_FILE="/var/lib/docker-backup/history.jsonl"
# Optional retained MQTT status and command listener settings. # Optional retained MQTT status and command listener settings.
MQTT_REPORT_ENABLED=0 MQTT_REPORT_ENABLED=0
+16 -13
View File
@@ -1,4 +1,4 @@
# Zorruno Docker Backup Scripts # Docker Backup Scripts
Modular backup scripts for Docker Compose servers. Modular backup scripts for Docker Compose servers.
Each server has its own untracked `.env` and `containers.local.txt`, while all script Each server has its own untracked `.env` and `containers.local.txt`, while all script
@@ -21,9 +21,9 @@ pruning on any failure, and exits non-zero so schedulers still detect the
problem. A partial archive run with successful transfers is reported as problem. A partial archive run with successful transfers is reported as
`partial`, not as full success. `partial`, not as full success.
Every stage can also be run directly. The old `docker-backup.sh` name invokes Stages can also be run directly. Use `stages/10-containers.sh` to create
the container archive stage, while `dockerbackup_prune.sh` invokes the local archives and `stages/90-prune.sh` to prune local archives. Use `backup.sh` to
prune stage. Use the new `backup.sh` for the complete pipeline. run the complete pipeline, including configured transfers and pruning.
## Requirements ## Requirements
@@ -35,12 +35,14 @@ prune stage. Use the new `backup.sh` for the complete pipeline.
- `rsync` and `mountpoint` only when the SMB method is enabled - `rsync` and `mountpoint` only when the SMB method is enabled
The account running the scripts must be allowed to control Docker and read all The account running the scripts must be allowed to control Docker and read all
files under `/dockervolumes`. files under `SOURCE_BASE_DIR`, and write to the directory containing
`BACKUP_HISTORY_FILE`.
## Installation on a server ## Installation on a server
```bash ```bash
sudo git clone https://home.fox.co.nz/gitea/zorruno/zorruno-backupdockerscript.git /backupdockerscripts REPOSITORY_URL="REPLACE_WITH_REPOSITORY_URL"
sudo git clone "$REPOSITORY_URL" /backupdockerscripts
cd /backupdockerscripts cd /backupdockerscripts
sudo cp .env.example .env sudo cp .env.example .env
sudo cp containers.txt containers.local.txt sudo cp containers.txt containers.local.txt
@@ -80,8 +82,8 @@ Copy `.env.example` to `.env`; `.env` is ignored by Git. Important values:
| `BACKUP_HOSTNAME` | Host folder/name embedded in archive filenames | | `BACKUP_HOSTNAME` | Host folder/name embedded in archive filenames |
| `BACKUP_METHODS` | Ordered method names, default `rclone smb` | | `BACKUP_METHODS` | Ordered method names, default `rclone smb` |
| `ZSTD_EXTRA_OPTS` | Options passed to `zstd`, default `-T0 -12` | | `ZSTD_EXTRA_OPTS` | Options passed to `zstd`, default `-T0 -12` |
| `TAR_EXCLUDES` | Space-separated archive paths to omit, relative to `SOURCE_BASE_DIR` | | `TAR_EXCLUDES` | Space-separated archive-member paths to omit, e.g. `project/data` |
| `BACKUP_HISTORY_FILE` | JSON Lines run-history file (default is shared with backup-status MCP) | | `BACKUP_HISTORY_FILE` | JSON Lines run-history file, default `/var/lib/docker-backup/history.jsonl` |
| `BACKUP_HISTORY_DAYS` | Days of completed run history to retain, default `30` | | `BACKUP_HISTORY_DAYS` | Days of completed run history to retain, default `30` |
| `BACKUP_REQUIRE_ENCRYPTED_STORAGE` | Refuse to run unless `/dockerbackups` is on `/srv/storage`; default `0` | | `BACKUP_REQUIRE_ENCRYPTED_STORAGE` | Refuse to run unless `/dockerbackups` is on `/srv/storage`; default `0` |
| `KEEP_COUNT` | Local archives retained per Compose project | | `KEEP_COUNT` | Local archives retained per Compose project |
@@ -158,7 +160,7 @@ MQTT_REPORT_ENABLED=1
MQTT_HOST="examplehostname" MQTT_HOST="examplehostname"
MQTT_PORT=1883 MQTT_PORT=1883
MQTT_USERNAME="dockerbackup" MQTT_USERNAME="dockerbackup"
MQTT_PASSWORD_FILE="/etc/zorruno-docker-backup/mqtt-password" MQTT_PASSWORD_FILE="/etc/docker-backup/mqtt-password"
MQTT_STATUS_TOPIC="backup-status/dockerbackup/examplehostname" MQTT_STATUS_TOPIC="backup-status/dockerbackup/examplehostname"
MQTT_COMMAND_TOPIC="backup-commands/dockerbackup/examplehostname/run" MQTT_COMMAND_TOPIC="backup-commands/dockerbackup/examplehostname/run"
``` ```
@@ -171,9 +173,9 @@ reported when MQTT remains available.
Install the optional root-run command listener with: Install the optional root-run command listener with:
```bash ```bash
cp systemd/zorruno-docker-backup-mqtt.service /etc/systemd/system/ cp systemd/docker-backup-mqtt.service /etc/systemd/system/
systemctl daemon-reload systemctl daemon-reload
systemctl enable --now zorruno-docker-backup-mqtt.service systemctl enable --now docker-backup-mqtt.service
``` ```
It accepts only JSON containing the exact action `run` on the configured It accepts only JSON containing the exact action `run` on the configured
@@ -202,8 +204,9 @@ BACKUP_METHODS="rclone smb restic"
``` ```
The main pipeline discovers the numbered file from the short name and runs it The main pipeline discovers the numbered file from the short name and runs it
after the earlier methods. A failed method stops the pipeline, so pruning will after the earlier methods. If a transfer method fails, remaining configured
not run after a failed transfer. methods are still attempted, pruning is skipped, and the overall run exits
non-zero.
## Archive and restore format ## Archive and restore format
+1 -1
View File
@@ -50,7 +50,7 @@ BACKUP_RUN_ID="$(run_id)"
BACKUP_STARTED_EPOCH="$(date +%s)" BACKUP_STARTED_EPOCH="$(date +%s)"
# Every script sourced through this process appends structured log lines here. # Every script sourced through this process appends structured log lines here.
# The MQTT reporting stage parses this temporary log to build its summary. # The MQTT reporting stage parses this temporary log to build its summary.
BACKUP_RUN_LOG="$(mktemp "${TMPDIR:-/tmp}/zorruno-docker-backup.XXXXXX.log")" BACKUP_RUN_LOG="$(mktemp "${TMPDIR:-/tmp}/docker-backup.XXXXXX.log")"
export BACKUP_RUN_ID BACKUP_STARTED_EPOCH BACKUP_RUN_LOG export BACKUP_RUN_ID BACKUP_STARTED_EPOCH BACKUP_RUN_LOG
finish_run() { finish_run() {
+3 -3
View File
@@ -20,10 +20,10 @@ PULL_IMAGES=1
START_TIMEOUT=90 START_TIMEOUT=90
WAIT_INTERVAL=3 WAIT_INTERVAL=3
START_RETRIES=1 START_RETRIES=1
LOCK_FILE="/run/lock/zorruno-docker-backup.lock" LOCK_FILE="/run/lock/docker-backup.lock"
ZSTD_EXTRA_OPTS="-T0 -12" ZSTD_EXTRA_OPTS="-T0 -12"
TAR_EXCLUDES="" TAR_EXCLUDES=""
BACKUP_HISTORY_FILE="/dockervolumes/openclaw/backup-status-mcp/history/backup-runs.jsonl" BACKUP_HISTORY_FILE="/var/lib/docker-backup/history.jsonl"
BACKUP_HISTORY_DAYS=30 BACKUP_HISTORY_DAYS=30
BACKUP_REQUIRE_ENCRYPTED_STORAGE=0 BACKUP_REQUIRE_ENCRYPTED_STORAGE=0
# Optional MQTT reporting and command-listener defaults. # Optional MQTT reporting and command-listener defaults.
@@ -80,7 +80,7 @@ is_true() {
} }
# Never let local backups silently fall back to the unencrypted root filesystem # Never let local backups silently fall back to the unencrypted root filesystem
# on hosts that opt in (for example, Beaver's encrypted backup drive). # on hosts that opt in.
if is_true "${BACKUP_REQUIRE_ENCRYPTED_STORAGE:-0}" && [[ "$BACKUP_ROOT" == "/dockerbackups" ]]; then if is_true "${BACKUP_REQUIRE_ENCRYPTED_STORAGE:-0}" && [[ "$BACKUP_ROOT" == "/dockerbackups" ]]; then
if ! mountpoint -q /srv/storage || ! mountpoint -q "$BACKUP_ROOT"; then if ! mountpoint -q /srv/storage || ! mountpoint -q "$BACKUP_ROOT"; then
die "Backup root is not mounted on encrypted storage; refusing to run." die "Backup root is not mounted on encrypted storage; refusing to run."
@@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Zorruno Docker backup MQTT command listener Description=Docker backup MQTT command listener
After=network-online.target docker.service After=network-online.target docker.service
Wants=network-online.target Wants=network-online.target