SPB Git forge
38commits 1branches 0releases
338.7 MBsize
maindefault branch
3 h agolast push
HTML 53.9% TypeScript 44.5% JavaScript 0.6% SQL 0.5%
1.7 KB · 33 lines shellscript
Raw Blame History
1#!/usr/bin/env bash2# backup.sh [--pull] [--pull-all] [--no-offsite]3# Runs deploy/bin/remote/backup-run.sh on the data node (same script the systemd timer runs):4#   pg_dump -Fc → /srv/dci/backups/pg/dci-<stamp>.dump5#   config/connectors + parser sources + git rev → /srv/dci/backups/config/dci-config-<stamp>.tar.zst6#   ClickHouse BACKUP DATABASE dci → /srv/dci/backups/clickhouse/dci-ch-<stamp>.zip (best effort)7#   mc mirror dci-raw → /srv/dci/backups/minio/dci-raw8#   retention 14 daily + 8 weekly, then rsync /srv/dci/backups → ubuntu@10.68.0.2:/srv/dci-backups (private link)9# --pull      also copy the latest pg dump + config tarball to ~/Backups/dci/ on this laptop10# --pull-all  copy the whole backups dir (including the MinIO mirror — can be large)11source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"12pull=0; pull_all=0; offsite=113for a in "$@"; do14  case "$a" in --pull) pull=1 ;; --pull-all) pull=1; pull_all=1 ;; --no-offsite) offsite=0 ;; *) die "unknown flag $a" ;; esac15done1617log "backup on $(host_for data)"18remote data "DCI_OFFSITE=$offsite $REMOTE_DIR/deploy/bin/remote/backup-run.sh"1920if [[ $pull == 1 ]]; then21  dest="$HOME/Backups/dci"; mkdir -p "$dest"22  if [[ $pull_all == 1 ]]; then23    log "pull everything → $dest"24    rsync -az --info=stats1 -e "ssh ${SSH_OPTS[*]}" "$(host_for data):$BACKUP_DIR/" "$dest/"25  else26    log "pull latest pg dump + config → $dest"27    latest_pg="$(remote data "ls -1t $BACKUP_DIR/pg/*.dump | head -1")"28    latest_cfg="$(remote data "ls -1t $BACKUP_DIR/config/*.tar.zst | head -1")"29    rsync -az --info=stats1 -e "ssh ${SSH_OPTS[*]}" "$(host_for data):$latest_pg" "$(host_for data):$latest_cfg" "$dest/"30  fi31  ok "pulled: $(ls -1t "$dest" | head -3 | tr '\n' ' ')"32fi33