34 lines
1.4 KiB
Bash
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/
|