OpenClaw 配置同步
🤖 我的 OpenClaw AI 助手配置文件 - 支持多设备快速迁移
仓库地址: https://github.com/NeiKetsu/openclaw-config
📦 包含内容
- ✅ 工作空间配置(scripts、docs、skills)
- ✅ 自定义脚本工具
- ✅ 文档和记忆系统
- ✅ Cron 定时任务配置
- ✅ 推送渠道配置
⚠️ 不包含(敏感信息)
- ❌
openclaw.json- 包含 API Key、Secret 等 - ❌
.gitconfig- 包含 GitHub Token - ❌
memory/- 个人记忆和上下文(可选) - ❌ 日志和缓存文件
🚀 新设备部署流程(完整指南)
前置条件
- ✅ 已安装 OpenClaw
- ✅ 已配置 Python 3.6+
- ✅ 已安装 Git
Step 1: 克隆配置仓库
# 备份现有配置(如果有)
mv ~/.openclaw/workspace ~/.openclaw/workspace.backup
# 克隆仓库
git clone https://github.com/NeiKetsu/openclaw-config.git ~/.openclaw/workspace
cd ~/.openclaw/workspace
Step 2: 配置敏感信息(⚠️ 必须)
这些文件不包含在仓库中,需要从原设备复制:
# 从原设备复制 openclaw.json
scp user@old-device:~/.openclaw/openclaw.json ~/.openclaw/
# 或手动编辑(填入你的 API Key、Secret 等)
nano ~/.openclaw/openclaw.json
# 配置 GitHub Token(用于脚本访问 GitHub API)
git config --global user.name "NeiKetsu"
git config --global user.email "[email protected]"
git config --global credential.helper store
# 首次 push 时会提示输入 Token
Step 3: 安装 Python 依赖
# 文件读取功能
pip install pdfplumber python-docx openpyxl python-pptx reportlab
# 其他可能需要的库
pip install requests pillow
Step 4: 配置定时任务(可选)
# 查看当前 crontab
crontab -l
# 导入备份的配置(如果有)
crontab crontab.backup
# 或手动编辑
crontab -e
# 添加:
# 0 8 * * * /root/.openclaw/workspace/scripts/morning_news.sh
# 0 9 * * * /tmp/tech_reminder.sh
# 0 20 * * * openclaw sessions spawn --label "evening-summary" --mode run --task "总结今天工作,查看明天日程,发送晚报到企业微信"
Step 5: 验证配置
# 检查 Gateway 状态
openclaw gateway status
# 测试脚本
./scripts/github_api.sh user | python3 -m json.tool
# 测试推送(企业微信)
openclaw message send --channel wecom --target NingJie -m "测试消息"
Step 6: 配置 Git 推送权限
# 设置仓库 URL(包含 Token)
# ⚠️ 将 YOUR_TOKEN 替换为你的实际 Token
cd ~/.openclaw/workspace
git remote set-url origin https://NeiKetsu:[email protected]/NeiKetsu/openclaw-config.git
# 或使用 credential helper(更安全)
git config --global credential.helper store
git push # 首次会提示输入 Token
🔄 日常同步
快速同步(推荐)
# 修改配置后上传
./scripts/sync-github.sh push
# 换设备后下载
./scripts/sync-github.sh pull
# 查看状态
./scripts/sync-github.sh status
⚠️ 敏感信息(不要提交)
以下文件已通过 .gitignore 排除,需要手动复制:
openclaw.json- API Key、Secret、推送配置~/.gitconfig- GitHub Tokenmemory/- 个人记忆(可选)*.log- 日志文件
📝 仓库维护指南
更新仓库的最佳实践
1. 定期提交(建议每周)
# 检查变更
./scripts/sync-github.sh status
# 提交更新
cd ~/.openclaw/workspace
git add .
git commit -m "更新配置:$(date '+%Y-%m-%d') - 简要说明变更内容"
git push
2. 重大变更后立即提交
- ✅ 添加新脚本/工具
- ✅ 修改配置文件结构
- ✅ 更新技能 (skills)
- ✅ 添加重要文档
3. 提交信息规范
# 格式
git commit -m "类型:简要描述
详细说明(可选)"
# 示例
git commit -m "feat: 添加 GitHub API 同步脚本"
git commit -m "fix: 修复早报推送渠道配置"
git commit -m "docs: 更新 README 部署指南"
git commit -m "config: 更新企业微信推送配置"
4. 清理不必要的文件
# 检查大文件
git count-objects -vH
# 清理缓存
git gc --prune=now
# 查看 .gitignore 是否生效
git check-ignore -v <filename>
版本管理(可选)
# 打标签(重要版本)
git tag -a v1.0.0 -m "初始版本 - 基础配置完成"
git push origin v1.0.0
# 查看历史版本
git tag -l
git show v1.0.0
回滚操作
# 查看提交历史
git log --oneline -10
# 回滚到指定版本
git reset --hard <commit-hash>
# 恢复远程仓库
git push --force origin master
🛠️ 故障排查
推送失败:Token 过期
# 更新 Token
git remote set-url origin https://NeiKetsu:[email protected]/NeiKetsu/openclaw-config.git
同步冲突
# 拉取远程变更
git fetch origin
# 查看冲突
git status
# 手动解决冲突后
git add .
git commit -m "解决同步冲突"
git push
误提交敏感信息
# 立即删除(本地)
git reset --hard HEAD~1
# 强制推送(远程)
git push --force origin master
# ⚠️ 立即作废泄露的 Token,生成新的
📁 目录结构
.
├── scripts/ # 自定义脚本
│ ├── github_api.sh # GitHub API 工具
│ ├── morning_news.sh # 早报推送
│ ├── read_file.py # 文件读取工具
│ └── sync-github.sh # 同步脚本
├── docs/ # 文档
├── skills/ # 自定义技能
├── memory/ # 记忆文件(不提交)
├── MEMORY.md # 长期记忆
├── SOUL.md # AI 人格配置
├── USER.md # 用户信息
├── TOOLS.md # 工具配置笔记
└── HEARTBEAT.md # 心跳检查配置
📊 仓库统计
# 查看仓库大小
du -sh ~/.openclaw/workspace
# 查看文件数量
find ~/.openclaw/workspace -type f | wc -l
# 查看 Git 历史
git log --oneline | wc -l
📝 更新日志
- 2026-03-18: 初始创建
- ✅ 基础配置同步
- ✅ 脚本工具集
- ✅ 新设备部署指南
- ✅ 仓库维护指南
作者: NeiX
GitHub: @NeiKetsu
No comments yet.