From 06aa75095c4b75be6d6ee731eec84f1b36f35e14 Mon Sep 17 00:00:00 2001 From: howard Date: Sun, 1 Nov 2026 11:50:58 +1300 Subject: [PATCH] Make encrypted storage requirement host configurable --- .env.example | 2 ++ README.md | 1 + lib/common.sh | 20 +++++++++++--------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 23024a0..533c2eb 100644 --- a/.env.example +++ b/.env.example @@ -18,6 +18,8 @@ ZSTD_EXTRA_OPTS="-T0 -12" TAR_EXCLUDES="" # Final backup-run reports retained locally for this many days. BACKUP_HISTORY_DAYS=30 +# Set to 1 when BACKUP_ROOT must reside on encrypted storage (e.g. Beaver). +BACKUP_REQUIRE_ENCRYPTED_STORAGE=0 # Optional retained MQTT status and command listener settings. MQTT_REPORT_ENABLED=0 diff --git a/README.md b/README.md index 768abad..7939f3f 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ Copy `.env.example` to `.env`; `.env` is ignored by Git. Important values: | `TAR_EXCLUDES` | Space-separated archive paths to omit, relative to `SOURCE_BASE_DIR` | | `BACKUP_HISTORY_FILE` | JSON Lines run-history file (default is shared with backup-status MCP) | | `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` | | `KEEP_COUNT` | Local archives retained per Compose project | | `PULL_IMAGES` | Pull images before restarting (`1` or `0`) | diff --git a/lib/common.sh b/lib/common.sh index f12d1c6..b5f20e3 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -25,6 +25,7 @@ ZSTD_EXTRA_OPTS="-T0 -12" TAR_EXCLUDES="" BACKUP_HISTORY_FILE="/dockervolumes/openclaw/backup-status-mcp/history/backup-runs.jsonl" BACKUP_HISTORY_DAYS=30 +BACKUP_REQUIRE_ENCRYPTED_STORAGE=0 # Optional MQTT reporting and command-listener defaults. MQTT_REPORT_ENABLED=0 MQTT_HOST="" @@ -71,8 +72,16 @@ return 0 } die() { log ERROR "$1"; exit "${2:-1}"; } -# Never let local backups silently fall back to the unencrypted root filesystem. -if [[ "$BACKUP_ROOT" == "/dockerbackups" ]]; then +is_true() { + case "${1,,}" in + 1|true|yes|on|enabled) return 0 ;; + *) return 1 ;; + esac +} + +# Never let local backups silently fall back to the unencrypted root filesystem +# on hosts that opt in (for example, Beaver's encrypted backup drive). +if is_true "${BACKUP_REQUIRE_ENCRYPTED_STORAGE:-0}" && [[ "$BACKUP_ROOT" == "/dockerbackups" ]]; then if ! mountpoint -q /srv/storage || ! mountpoint -q "$BACKUP_ROOT"; then die "Backup root is not mounted on encrypted storage; refusing to run." fi @@ -83,13 +92,6 @@ if [[ "$BACKUP_ROOT" == "/dockerbackups" ]]; then fi fi -is_true() { - case "${1,,}" in - 1|true|yes|on|enabled) return 0 ;; - *) return 1 ;; - esac -} - require_command() { command -v "$1" >/dev/null 2>&1 || die "Required command not found: $1" 3 }