#!/usr/bin/env bash # backup.sh [--pull] [--pull-all] [--no-offsite] # Runs deploy/bin/remote/backup-run.sh on the data node (same script the systemd timer runs): # pg_dump -Fc → /srv/dci/backups/pg/dci-.dump # config/connectors + parser sources + git rev → /srv/dci/backups/config/dci-config-.tar.zst # ClickHouse BACKUP DATABASE dci → /srv/dci/backups/clickhouse/dci-ch-.zip (best effort) # mc mirror dci-raw → /srv/dci/backups/minio/dci-raw # retention 14 daily + 8 weekly, then rsync /srv/dci/backups → ubuntu@10.68.0.2:/srv/dci-backups (private link) # --pull also copy the latest pg dump + config tarball to ~/Backups/dci/ on this laptop # --pull-all copy the whole backups dir (including the MinIO mirror — can be large) source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" pull=0; pull_all=0; offsite=1 for a in "$@"; do case "$a" in --pull) pull=1 ;; --pull-all) pull=1; pull_all=1 ;; --no-offsite) offsite=0 ;; *) die "unknown flag $a" ;; esac done log "backup on $(host_for data)" remote data "DCI_OFFSITE=$offsite $REMOTE_DIR/deploy/bin/remote/backup-run.sh" if [[ $pull == 1 ]]; then dest="$HOME/Backups/dci"; mkdir -p "$dest" if [[ $pull_all == 1 ]]; then log "pull everything → $dest" rsync -az --info=stats1 -e "ssh ${SSH_OPTS[*]}" "$(host_for data):$BACKUP_DIR/" "$dest/" else log "pull latest pg dump + config → $dest" latest_pg="$(remote data "ls -1t $BACKUP_DIR/pg/*.dump | head -1")" latest_cfg="$(remote data "ls -1t $BACKUP_DIR/config/*.tar.zst | head -1")" rsync -az --info=stats1 -e "ssh ${SSH_OPTS[*]}" "$(host_for data):$latest_pg" "$(host_for data):$latest_cfg" "$dest/" fi ok "pulled: $(ls -1t "$dest" | head -3 | tr '\n' ' ')" fi