#!/usr/bin/env bash # raiden-synk.sh — rsynk /mnt/raiden/hot to /mnt/raiden/cold # Usage: raiden-synk.sh [--dry-run] SRC="/mnt/raiden/hot/" DST="/mnt/raiden/cold/" LOG="/mnt/raiden/cold/raiden-synk.log" # ── colours ─────────────────────────────────────────────────────────────────── RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' info() { echo -e "${GREEN}[✔]${NC} $*" | tee -a "$LOG"; } warn() { echo -e "${YELLOW}[!]${NC} $*" | tee -a "$LOG"; } error() { echo -e "${RED}[✘]${NC} $*" | tee -a "$LOG"; exit 1; } # ── preflight checks ────────────────────────────────────────────────────────── echo "" | tee -a "$LOG" info "$(date '+%Y-%m-%d %H:%M:%S') — raiden-synk starting" # Vaults mounted? mountpoint -q "$SRC" || error "Hot vault not mounted at $SRC — open it first" mountpoint -q "$DST" || error "Cold vault not mounted at $DST — open it first" info "Source : $SRC" info "Dest : $DST" # ── dry run? ────────────────────────────────────────────────────────────────── DRYRUN="" if [ "$1" = "--dry-run" ]; then DRYRUN="--dry-run" warn "Dry run mode — no files will be written" fi # ── rsync ───────────────────────────────────────────────────────────────────── rsync -avh --progress --delete --exclude=Thumbs.db:encryptable --exclude=Thumbs.db --exclude=debug.log \ $DRYRUN \ "$SRC" "$DST" \ | tee -a "$LOG" STATUS=${PIPESTATUS[0]} # ── result ──────────────────────────────────────────────────────────────────── if [ "$STATUS" -eq 0 ]; then info "Sync complete." elif [ "$STATUS" -eq 24 ]; then warn "Sync complete with warnings (some files vanished during transfer — usually harmless)." else error "rsync failed with exit code $STATUS" fi