OpenClaw Updater
Safely update OpenClaw with automatic pre-flight safety checks and rollback capability.
Pre-Update Checklist
Before running openclaw update, always run the pre-update script:
CODEBLOCK0
Optional: specify a backup script to run during pre-flight:
CODEBLOCK1
The script will:
- 1. Find all
workspace* directories under INLINECODE2 - Git commit any uncommitted changes (init git if missing)
- Back up
openclaw.json to INLINECODE4 - Run the backup script if provided
- Save the current version to INLINECODE5
Telegram Notification Setup
The update script sends success/failure notifications via Telegram Bot API (bypasses OpenClaw gateway, so it works even if the update breaks the gateway).
Create ~/.openclaw/.telegram-notify.env:
CODEBLOCK2
CODEBLOCK3
The bot token is the same one used by your OpenClaw Telegram channel. Chat ID can be found via openclaw directory.
Update (with notification)
Run the full update with automatic pre-flight + notification:
CODEBLOCK4
This will: pre-flight → update → wait for gateway → notify via Telegram.
Update (manual)
After pre-flight passes:
CODEBLOCK5
Post-Update Verification
After updating, verify:
CODEBLOCK6
Check that:
- - Version shows the new release
- Gateway is running
- All agents are responsive
Rollback
If the update breaks something:
CODEBLOCK7
The script will:
- 1. Read the saved previous version from INLINECODE8
- Install that version via INLINECODE9
- Optionally restore
openclaw.json from backup - Restart the gateway
Manual Rollback
If the rollback script isn't available:
CODEBLOCK8
Restore from Full Backup
If config and workspaces are both corrupted:
CODEBLOCK9
OpenClaw 更新器
通过自动预检安全检查和回滚能力,安全地更新 OpenClaw。
更新前检查清单
在运行 openclaw update 之前,始终先运行预更新脚本:
bash
bash scripts/pre-update.sh
可选:在预检期间指定一个备份脚本:
bash
BACKUP_SCRIPT=~/repo/scripts/backup-openclaw.sh bash scripts/pre-update.sh
该脚本将:
- 1. 查找 ~/.openclaw/ 下所有 workspace* 目录
- Git 提交所有未提交的更改(如缺少 Git 则初始化)
- 将 openclaw.json 备份到 /tmp/openclaw.json.bak
- 如果提供了备份脚本则运行它
- 将当前版本保存到 /tmp/openclaw-prev-version.txt
Telegram 通知设置
更新脚本通过 Telegram Bot API 发送成功/失败通知(绕过 OpenClaw 网关,因此即使更新破坏了网关也能正常工作)。
创建 ~/.openclaw/.telegram-notify.env:
TELEGRAMBOTTOKEN=<你的机器人令牌>
TELEGRAMCHATID=<你的聊天ID>
bash
chmod 600 ~/.openclaw/.telegram-notify.env
机器人令牌与你的 OpenClaw Telegram 频道使用的令牌相同。聊天ID可通过 openclaw directory 找到。
更新(带通知)
运行包含自动预检和通知的完整更新:
bash
bash scripts/update.sh
这将执行:预检 → 更新 → 等待网关 → 通过 Telegram 通知。
更新(手动)
预检通过后:
bash
openclaw update
更新后验证
更新后,验证:
bash
openclaw status
openclaw gateway status
检查:
- - 版本显示为新版本
- 网关正在运行
- 所有代理均响应正常
回滚
如果更新出现问题:
bash
bash scripts/rollback.sh
该脚本将:
- 1. 从 /tmp/openclaw-prev-version.txt 读取保存的先前版本
- 通过 npm install -g openclaw@<版本> 安装该版本
- 可选地从备份恢复 openclaw.json
- 重启网关
手动回滚
如果回滚脚本不可用:
bash
安装特定版本
npm install -g openclaw@<版本>
恢复配置
cp /tmp/openclaw.json.bak ~/.openclaw/openclaw.json
重启
openclaw gateway restart
从完整备份恢复
如果配置和工作区都已损坏:
bash
查找最新备份
ls -t ~/repo/backups/openclaw-*.tar.gz | head -1
恢复(覆盖 ~/.openclaw/)
tar xzf ~/repo/backups/openclaw-<时间戳>.tar.gz -C ~/