infra/@kt-station.infra/mirror/scripts/sync-server.sh
#!/bin/bash
# sync-server.sh — синхронизация сервера на ПК
# Запуск: bash <(curl -s http://91.218.142.168/files/sync-server.sh)

SERVER="91.218.142.168"
BASE="$HOME/SERVER"

echo "=== Синхронизация с сервером — $(date) ==="

sync_dir() {
    local SRC="$1"
    local DST="$2"
    local NAME="$3"
    shift 3
    echo -n "$NAME... "
    rsync -az --delete \
        --exclude='.git/objects/' \
        "$@" \
        -e "ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10" \
        "root@$SERVER:$SRC" "$DST" 2>&1 | tail -1
    echo "✓"
}

sync_dir "/opt/claude-workspace/" "$BASE/workspace/" "workspace"
sync_dir "/var/www/html/files/"   "$BASE/files/"     "files"
sync_dir "/mnt/beget-s3/"         "$BASE/dataspace/" "dataspace" --exclude='up/' --exclude='dl/'
sync_dir "/mnt/beget-infra/"      "$BASE/infra/"     "infra"

echo "=== Готово $(date '+%H:%M') ==="