#!/bin/bash # Second independent copy of the historical archive (spec §154–155): pg_dump files + object store from the production node to the # gateway M1M32 (~/backups/company-atlas). Run from the laptop (or cron on M1M32). Incremental rsync; never deletes on the target. # Usage: scripts/backup-offnode.sh [NODE=M2U64] [TARGET=M1M32] set -euo pipefail NODE=${1:-M2U64} TARGET=${2:-M1M32} ssh "$NODE" 'cd ~/apps/company-atlas && export PATH=/opt/homebrew/opt/postgresql@17/bin:$PATH CA_DATA_DIR=$HOME/company-atlas-data DATABASE_URL=postgresql+asyncpg://companyatlas:companyatlas@127.0.0.1:5432/companyatlas && .venv/bin/catlas backup --keep 14 | tail -1' NODE_IP=$(ssh "$NODE" 'ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1') ssh "$TARGET" "mkdir -p ~/backups/company-atlas/{backups,objects} && rsync -a --ignore-existing simon-pierreboucher@${NODE_IP}:company-atlas-data/backups/ ~/backups/company-atlas/backups/ && rsync -a --ignore-existing simon-pierreboucher@${NODE_IP}:company-atlas-data/objects/ ~/backups/company-atlas/objects/ && du -sh ~/backups/company-atlas/*" echo "off-node copy on $TARGET:~/backups/company-atlas done $(date)"