#!/usr/bin/env bash # # Weekly SkateSpots relay archive + optional offsite copy. # # Driven by the systemd user timer `skatespots-archive.timer` (install with # scripts/install-archive-timer.sh). Local archives land in # ~/.backups/relay; if ~/.config/skatespots/restic.env exists, the whole # directory is pushed to a restic repository (S3/R2/B2/SFTP) and old snapshots # are pruned. Without that file the archive is local-only — still useful, but # not a real offsite backup. # # Manual run / debug: # scripts/backup-relay.sh # journalctl --user -u skatespots-archive -n 50 set -euo pipefail REPO="/home/sovereignsk8/SkateSpots" # systemd runs with a minimal PATH; node lives under nvm here. export PATH="/home/sovereignsk8/.nvm/versions/node/v22.23.1/bin:$PATH" ARCHIVE_DIR="${SKATESPOTS_ARCHIVE_DIR:-$HOME/.backups/relay}" RESTIC_ENV="$HOME/.config/skatespots/restic.env" log() { echo "[$(date -Is)] $*"; } mkdir -p "$ARCHIVE_DIR" cd "$REPO" log "archiving the community relay…" node scripts/archive-relay.mjs if [ -f "$RESTIC_ENV" ]; then # shellcheck disable=SC1090 set -a; . "$RESTIC_ENV"; set +a if [ -z "${RESTIC_REPOSITORY:-}" ]; then log "restic.env present but RESTIC_REPOSITORY is empty — skipping offsite copy" exit 0 fi log "pushing to restic $RESTIC_REPOSITORY…" restic backup --tag skatespots-relay "$ARCHIVE_DIR" restic forget --tag skatespots-relay --keep-last 12 --prune log "offsite copy done" else log "no $RESTIC_ENV — archive kept local-only (set one up for a real offsite backup)" fi