#!/usr/bin/env bash # scripts/migrate-onyx.sh — Phase 2 migration helper. # # Usage: # ./migrate-onyx.sh # # Example: # ./migrate-onyx.sh "$HOME/Downloads/qbt/" \ # /home/user/media/_downloads/complete/ # # What it does: # 1. rsync → user@nullstone: over LAN. # 2. Copies onyx's .torrent + .fastresume files to /tmp/qbt-migrate/ # on nullstone (you mass-add them via qbt webui afterwards). # 3. Prints a checklist of remaining manual steps. # # Pre-reqs: # - run from onyx (the SOURCE machine). # - ssh user@nullstone reachable on LAN. # - nullstone qbt stack already up (Phase 1 complete) — check with # `bash killswitch-test.sh` first. set -euo pipefail SRC="${1:-}" DST="${2:-}" NULLSTONE="${NULLSTONE_SSH:-user@192.168.0.100}" DRY_RUN="${DRY_RUN:-1}" usage() { cat < Env: NULLSTONE_SSH default: user@192.168.0.100 DRY_RUN default: 1 (rsync --dry-run). Set DRY_RUN=0 to actually copy. Example (dry-run): $0 "\$HOME/Downloads/qbt/" /home/user/media/_downloads/complete/ Example (real): DRY_RUN=0 $0 "\$HOME/Downloads/qbt/" /home/user/media/_downloads/complete/ EOF exit 2 } [ -z "$SRC" ] || [ -z "$DST" ] && usage [ -d "$SRC" ] || { echo "Source dir not found: $SRC" >&2; exit 1; } QBT_BACKUP="$HOME/.local/share/qBittorrent/BT_backup" [ -d "$QBT_BACKUP" ] || { echo "qBittorrent BT_backup dir missing: $QBT_BACKUP" >&2; exit 1; } RSYNC_FLAGS=(-av --info=progress2 --partial --human-readable) if [ "$DRY_RUN" = "1" ]; then RSYNC_FLAGS+=(--dry-run) echo "=== DRY-RUN — no data will be copied. Set DRY_RUN=0 to run for real. ===" fi echo "=== Step 1/3: rsync data files to nullstone ===" rsync "${RSYNC_FLAGS[@]}" "$SRC" "$NULLSTONE:$DST" echo echo "=== Step 2/3: ship .torrent + .fastresume to nullstone /tmp/qbt-migrate/ ===" ssh "$NULLSTONE" "mkdir -p /tmp/qbt-migrate" if [ "$DRY_RUN" = "1" ]; then echo "(dry-run) would scp $QBT_BACKUP/*.torrent $QBT_BACKUP/*.fastresume → $NULLSTONE:/tmp/qbt-migrate/" else scp -q "$QBT_BACKUP"/*.torrent "$QBT_BACKUP"/*.fastresume "$NULLSTONE:/tmp/qbt-migrate/" fi echo echo "=== Step 3/3: remaining manual steps ===" cat <