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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
This commit is contained in:
JasonFraser 2026-10-03 23:39:14 -04:00
parent e863fcdb5b
commit 9faeeb7ee0
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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