SkateSpots/scripts/backup-relay.sh
SkateSpots c01521ea3f feat(backup): scoped weekly archive of the community relay dataset
scripts/archive-relay.mjs snapshots the app's own content off
goskatespots.nostr1.com to gzipped JSONL of the raw signed events, so a
restore can republish them verbatim to any relay. scripts/restore-relay.mjs
re-verifies signatures and publishes to an explicit --to (no default, to
avoid replaying a snapshot onto the live relay). scripts/backup-relay.sh
wraps it and pushes with restic when a repo is configured; a weekly systemd
user timer runs it.

Scoped on purpose: that relay is PUBLIC and carries general traffic (15.7k
kind-0 profiles, 2k kind-30078 app-data from other clients, 408 foreign
NIP-99 listings), so the archive keeps only the app's own kinds/tags plus
contributor profiles, SkateSpots labels, and reports that reference archived
content. ~114 events / 63 KiB.

Not configured yet: offsite (restic.env) and a full restore drill.
2026-09-28 12:41:50 +07:00

45 lines
1.5 KiB
Bash
Executable file

#!/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