hephaestus/scripts/sync-hephaestus-x-to-sia.sh
Local Dev 8d9b3a8a7a feat(hephaestus): make hephaestus.x served from VPS with Sia as DR backup
Architecture shift: hephaestus.x used to be Sia-bucket-only (via bns-gateway's
s3: record type). Now it's VPS-served with Silent Mode CA cert; the Sia bucket
stays populated as a disaster-recovery mirror that a single Argus CLI call
(update.js flipping ip: → s3:) can promote back to primary if the VPS dies.

Every code.silentmode.st URL now also works at hephaestus.x — the same Caddy
handles both hostnames; hephaestus.x additionally checks /srv/hephaestus.x/
for a matching static file first, so /forge/, /silentmode/theseus/, and the
other landing pages don't get eaten by Forgejo's dynamic routes.

- caddy/Caddyfile: add hephaestus.x server block with the Argonautica-issued
  cert; static-first, Forgejo-fallback
- docker-compose.yml: mount ./caddy (whole dir, for certs/) and
  /var/www/hephaestus.x → /srv/hephaestus.x
- scripts/sync-hephaestus-x-to-sia.sh: nightly rclone sync as DR backup

Off-tree changes (kept in memory record for future sessions):
- Silent Mode CA issued hephaestus.x.crt (fingerprint
  6e251c2bb4987e66890aa28ebc8e16df5dfe03c1fc559634246ae69c2e00400b)
- BCNR record on hephaestus.x flipped to {"ip":"81.31.210.65","tls":"6e251c2b..."}
  (TXID fdd301a2ae313636f71ec4dfba9a3ff723a9158b4a3937ac4ce0a83b3f8cda11)
- systemd timer hephaestus-x-sia-sync.timer on the p2pexchange VPS, 03:35 UTC daily
2026-08-31 15:52:41 +02:00

34 lines
1.4 KiB
Bash

#!/usr/bin/env bash
# sync-hephaestus-x-to-sia.sh — nightly disaster-recovery backup of the
# static hephaestus.x content from VPS to the Sia bucket.
#
# The BCNR record on hephaestus.x currently points at the VPS via `ip:` only,
# so users route through this VPS. This script keeps a parallel copy on Sia
# for disaster recovery: if the VPS dies, updating the BCNR record from
# `ip:` back to `s3:"bns/hephaestus.x/"` (single Argus CLI call) restores
# service from the Sia bucket in the time it takes for one BCH transaction
# to confirm on chipnet.
#
# Runs on the p2pexchange VPS via systemd timer (hephaestus-x-sia-sync.timer).
set -euo pipefail
cd "$(dirname "$0")/.." # → /root/hephaestus
set -a; source .env; set +a
: "${SIA_STORAGE_ENDPOINT:?}"
: "${SIA_STORAGE_ACCESS_KEY:?}"
: "${SIA_STORAGE_SECRET_KEY:?}"
# Use rclone with an inline S3 remote — no config file needed.
export RCLONE_CONFIG_SIA_TYPE=s3
export RCLONE_CONFIG_SIA_PROVIDER=Other
export RCLONE_CONFIG_SIA_ENDPOINT="https://${SIA_STORAGE_ENDPOINT}"
export RCLONE_CONFIG_SIA_ACCESS_KEY_ID="$SIA_STORAGE_ACCESS_KEY"
export RCLONE_CONFIG_SIA_SECRET_ACCESS_KEY="$SIA_STORAGE_SECRET_KEY"
export RCLONE_CONFIG_SIA_REGION=us-east-1
echo "[$(date -u +%FT%TZ)] syncing /var/www/hephaestus.x/ → sia:bns/hephaestus.x/"
rclone sync /var/www/hephaestus.x/ sia:bns/hephaestus.x/ --checksum
echo "[$(date -u +%FT%TZ)] done. bucket contents:"
rclone size sia:bns/hephaestus.x/