From 9faeeb7ee067c650c0b71858430cd1046570675d Mon Sep 17 00:00:00 2001 From: JasonFraser Date: Sat, 3 Oct 2026 23:39:14 -0400 Subject: [PATCH] backup.sh: self-install rclone if missing, matching restore.sh Confirmed the hard way on a fresh VPS: backup.sh stopped every writer container, archived everything, then failed outright on "rclone: command not found" during the upload step -- restore.sh already self-installs rclone (same rclone.org/install.sh) for exactly this scenario, backup.sh just never got the same treatment. Checked up front now, before anything stateful (stopping containers) happens. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y --- backup/backup.sh | 10 ++++++++++ playbook/INSTALLATION_PLAYBOOK.md | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/backup/backup.sh b/backup/backup.sh index 05e4a83..a79a044 100755 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -48,6 +48,16 @@ set -a; source "${ENV_FILE}"; set +a RETENTION_DAILY_DAYS="${RETENTION_DAILY_DAYS:-14}" RETENTION_WEEKLY_DAYS="${RETENTION_WEEKLY_DAYS:-56}" +# Confirmed the hard way: nothing installs rclone on a fresh VPS before this +# script's first run — restore.sh already self-installs it (mirrored here, +# same install.sh), but backup.sh didn't, so the very first scheduled run on +# a brand-new box failed after already stopping every writer container. +# Checked up front, before anything stateful happens below. +if ! command -v rclone >/dev/null 2>&1; then + echo "backup.sh: rclone not found — installing via rclone's official script..." + curl -fsSL https://rclone.org/install.sh | sh +fi + # The exact writer set: everything that touches sites/db-data/redis-queue-data/ # billing-state. redis-cache and configurator are deliberately excluded — # redis-cache holds nothing persistent (no volume at all) and configurator diff --git a/playbook/INSTALLATION_PLAYBOOK.md b/playbook/INSTALLATION_PLAYBOOK.md index fc21dae..9b907bd 100644 --- a/playbook/INSTALLATION_PLAYBOOK.md +++ b/playbook/INSTALLATION_PLAYBOOK.md @@ -547,7 +547,10 @@ and every gotcha found building it: [`BACKUP_RESTORE.md`](./BACKUP_RESTORE.md). screen; see `BACKUP_RESTORE.md` for exactly where to look. - Retention days, if you want something other than 14 daily / 8 weekly (56 days). 2. Test one backup by hand — `./backup/backup.sh` — confirm it completes and the archive shows up - in the R2 bucket's `daily/` prefix before trusting it to cron. + in the R2 bucket's `daily/` prefix before trusting it to cron. ⚠ **Confirmed the hard way:** on + a brand-new VPS this first run installs `rclone` itself (same self-install `restore.sh` already + did) — nothing to do manually, but the very first run takes a few seconds longer and prints an + install log before the actual backup starts. 3. Add the cron job: ``` crontab -e