#!/bin/bash # Copy Market Atlas backups (pg_dump metadata) and the observation archive from the production node to the gateway. # Usage: scripts/backup-offnode.sh [node] [dest-host] (defaults: M2U64 → M1M32:~/backups/market-atlas) set -euo pipefail NODE=${1:-M2U64} DEST=${2:-M1M32} ssh "$DEST" 'mkdir -p ~/backups/market-atlas/{backups,archive}' ssh "$NODE" 'ls ~/market-atlas-data/backups | tail -3' # Node → laptop → gateway (nodes reach each other on the LAN, but keep the laptop as the pivot so agent forwarding works everywhere). TMP=$(mktemp -d) rsync -a --delete "$NODE:~/market-atlas-data/backups/" "$TMP/backups/" rsync -a "$NODE:~/market-atlas-data/archive/" "$TMP/archive/" rsync -a "$TMP/backups/" "$DEST:~/backups/market-atlas/backups/" rsync -a "$TMP/archive/" "$DEST:~/backups/market-atlas/archive/" rm -rf "$TMP" ssh "$DEST" 'du -sh ~/backups/market-atlas'