Files
dsh_shenxian/scripts/switch-B2b-push.sh
T
admin 5ec99ce227
build / build-and-scan (push) Canceled after 0s
chore: 文档库全量重新入库(2026-10-20)
2026-10-20 15:05:55 +08:00

32 lines
1.7 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
. "$(cd "$(dirname "$0")/.." && pwd)/config/load.sh"
# B2' 步:47 → 106 直推生产 dataRoot(tar-over-ssh;只用命令执行,绕开 rsync 协议问题)
# · tar --numeric-owner 保 uid/gid(否则 106 上属主错 ⇒ 实例 EACCES)
# · 排除 dshs.db*(权威源=47 的 PG)与 secret.key(主密钥不外扩 —— R5 最小面)
set -uo pipefail
KEY=/root/.ssh/dshworker_ed25519
DST=root@"$DSH_PEER_PUBLIC_IP"
SSHO="-i $KEY -o BatchMode=yes -o StrictHostKeyChecking=accept-new"
echo "=== 1) 目标端准备(ssh -n 防抢 stdin) ==="
ssh -n $SSHO "$DST" "mkdir -p $DSHS_DATA_ROOT && echo ready: \$(ls -ld $DSHS_DATA_ROOT)"
echo "=== 2) 推送(tar → ssh → tar --numeric-owner -x) ==="
cd "$DSHS_DATA_ROOT"
tar --numeric-owner -cf - \
--exclude=./dshs.db --exclude=./dshs.db-shm --exclude=./dshs.db-wal --exclude=./secret.key \
. | ssh $SSHO "$DST" "tar -C $DSHS_DATA_ROOT --numeric-owner -xf -"
rc=$?
echo " 管道 rc=$rc"
echo "=== 3) 目标端核对 ==="
ssh -n $SSHO "$DST" 'bash -c "
echo \" 顶层: \$(ls "$DSHS_DATA_ROOT" | tr \"\n\" \" \")\"
echo \" 总量: \$(du -sh "$DSHS_DATA_ROOT" | cut -f1)\"
echo \" users 目录数: \$(ls "$DSHS_DATA_ROOT"/users | wc -l)\"
echo \" --- 属主抽样(应与 47 的 uid 一致) ---\"
for d in "$DSHS_DATA_ROOT"/users/*/; do printf \" %-38s uid=%s\n\" \"\$(basename \$d)\" \"\$(stat -c %u \$d)\"; done
echo \" bundled-skills=\$(ls "$DSHS_DATA_ROOT"/bundled-skills | wc -l) business-plugins=\$(ls "$DSHS_DATA_ROOT"/business-plugins | wc -l)\"
echo \" ⛔ 不该有 dshs.db/secret.key: \$(ls "$DSHS_DATA_ROOT"/dshs.db "$DSHS_DATA_ROOT"/secret.key 2>/dev/null | wc -l) 个(应 0)\"
"'