Knowledge Sync

👤 alfredming-2026 📦 v1.0.0 ⭐ 4.1 ⬇️ 889 下載
📚 知識管理 免費

📖 技能介紹


name: knowledge-sync version: 1.0.0 description: Real-time knowledge base synchronization for AI assistants. Supports inotifywait file monitoring, Git auto-push/pull, Nutstore sync, and multi-device consistency. Use for maintaining knowledge continuity across servers and local devices.


Knowledge Sync - 知識庫同步機制

核心原則: Text > Brain,檔案 > 記憶,同步 > 備份


🚀 快速開始

systemd 服務配置

# 啟用即時同步服務
systemctl --user enable sync-realtime.service
systemctl --user start sync-realtime.service

Crontab 配置

# 每 5 分鐘 Git push
*/5 * * * * /path/to/git-auto-push.sh

# 每小時 Git pull
0 * * * * cd /path/to/workspace && git pull origin main --rebase

🔧 核心功能

1. 即時同步

  • ✅ inotifywait 檔案監聽
  • ✅ 3-10 秒同步延遲
  • ✅ 6 個目錄監聽(articles/memory/projects/docs/scripts/learnings)
  • ✅ 自動排除(node_modules/pycache/.git)

2. Git 備份

  • ✅ 每 5 分鐘自動 push
  • ✅ 每小時自動 pull
  • ✅ 衝突檢測和解決
  • ✅ Gitee 遠端備份

3. 多端同步

  • ✅ 伺服器→堅果雲→Mac Obsidian
  • ✅ 雙向同步支援
  • ✅ 多端一致性保障

📁 包含檔案

knowledge-sync/
├── SKILL.md                  # 主文件
├── README.md                 # 專案說明
├── scripts/
│   ├── sync-realtime.sh      # 即時同步指令碼
│   ├── git-auto-push.sh      # Git 自動推送
│   └── git-auto-pull.sh      # Git 自動拉取
└── docs/
    ├── QUICKSTART.md         # 快速上手
    └── sync-guide.md         # 同步指南

📊 同步架構

伺服器 Workspace → 堅果雲實時監聽 → 本地同步 → Gitee → Mac Obsidian
         3-10 秒           即時         ≤5 分鐘    ≤5 分鐘

總延遲: 5-10 分鐘(主要等待 Git 推送週期)


💡 使用場景

1. 即時檔案同步

# 啟動即時同步服務
systemctl --user start sync-realtime.service

# 檢視狀態
systemctl --user status sync-realtime.service

2. Git 自動備份

# 手動推送
./git-auto-push.sh

# 或定時執行
*/5 * * * * ./git-auto-push.sh

3. 多端同步

# Mac 端拉取
cd ~/Obsidian-MKH/我的知識/OpenClaw
git pull origin main

🔧 配置說明

監聽目錄配置

WATCH_DIRS=(
    "/path/to/workspace/articles"
    "/path/to/workspace/memory"
    "/path/to/workspace/projects"
    "/path/to/workspace/docs"
    "/path/to/workspace/scripts"
    "/path/to/workspace/learnings"
)

排除模式

EXCLUDE_PATTERN="\\.(log|tmp|swp|pyc)$|node_modules|__pycache__|\\.git"

📈 監控指標

指標 正常值 警告值
同步延遲 <10 秒 >30 秒
Git push 間隔 5 分鐘 >10 分鐘
Git pull 間隔 1 小時 >2 小時
衝突次數 0 >1/周

🎓 最佳實踐

1. 同步頻率

  • 即時同步:inotifywait 監聽(3-10 秒)
  • Git push:每 5 分鐘
  • Git pull:每小時

2. 衝突處理

  • push 前先 pull

    來源於7w4.net。

  • 大改動分多次 commit
  • 人工編輯前先 git pull

3. 備份策略

  • Git 遠端備份(Gitee)
  • 堅果雲本地備份
  • 定期完整備份(每週)

📝 更新日誌

v1.0.0 (2026-03-15)

  • ✅ 初始版本釋出
  • ✅ 即時同步功能
  • ✅ Git 自動備份
  • ✅ 多端同步支援

維護者: 蝦球 🦐
許可: MIT
狀態: 生產環境執行中

🤖 AI 評測

這個工具質量中等偏上,核心的即時同步和 Git 自動備份功能做得不錯,能幫助實現多裝置間的知識同步。但存在文件與實際內容不符的問題——有些承諾的功能實際缺失,而且某些細節處理比較粗糙。對於需要穩定多端同步的使用者來說基本可用,但建議先驗證所有功能是否正常再依賴它做重要備份。

📊 多維度評分

適應性4
規範性4.1
有效性4.1
可靠性3.7
可信度5

📁 包含檔案 (6 個)

📄 README.md 1.2 KB
📄 SKILL.md 3.5 KB
📄 _meta.json 133 B
📄 scripts/git-auto-push.sh 953 B
📄 scripts/sync-realtime.sh 7.3 KB
📄 skill-card.md 2.6 KB