Reinstall OpenClaw Skill
This skill provides complete procedures to safely uninstall and reinstall OpenClaw while preserving all user configurations, credentials, memory files, skills, and custom settings.
Use Cases
- - Clean reinstall of OpenClaw to fix corrupted installations
- Remove third-party modifications and restore to official version
- Upgrade to latest version with fresh installation
- Migrate OpenClaw to a new environment with existing configurations
Prerequisites
- - WSL (Ubuntu 20.04 or later) or Linux/macOS with Node.js
- Node.js 18+ and npm/pnpm
- Access to WSL terminal (for Windows users)
Complete Procedure
Step 1: Check Current Installation
First, identify the OpenClaw installation location and version:
CODEBLOCK0
Step 2: Backup All User Data
Create a complete backup of all user configurations:
CODEBLOCK1
What to Backup (Already included in ~/.openclaw)
| Directory/File | Description |
|---|
| INLINECODE0 | Main configuration (gateway token, API keys, channel configs) |
| INLINECODE1 |
API credentials and secrets |
|
memory/ | SQLite memory database |
|
agents/ | Agent configurations and sessions |
|
skills/ | Installed skills |
|
workspace/ | User workspace (SOUL.md, IDENTITY.md, AGENTS.md, etc.) |
|
feishu/ | Feishu configuration |
|
identity/ | Device identity files |
|
devices/ | Paired devices |
|
cron/ | Scheduled cron jobs |
Step 3: Stop OpenClaw Services
Stop all running OpenClaw processes:
CODEBLOCK2
Step 4: Uninstall OpenClaw
Use the official uninstall command:
CODEBLOCK3
Note: The --all flag removes the CLI as well. If you want to keep the CLI for reinstallation, omit this flag.
Step 5: Clean Up Remaining Files
Remove any remaining files that might interfere:
CODEBLOCK4
Step 6: Install Latest OpenClaw
Install the latest official version:
CODEBLOCK5
Step 7: Restore User Configuration
Restore your backed-up configurations:
CODEBLOCK6
Step 8: Run Health Check and Fix
CODEBLOCK7
Step 9: Start OpenClaw Gateway
CODEBLOCK8
Complete One-Liner Backup Script
Run this before uninstalling to create a timestamped backup:
CODEBLOCK9
Complete One-Liner Restore Script
Run this after reinstallation to restore configurations:
CODEBLOCK10
Troubleshooting
Gateway won't start after restore
CODEBLOCK11
Port already in use
CODEBLOCK12
Configuration errors after restore
CODEBLOCK13
Permission issues
CODEBLOCK14
Files Reference
Configuration File (~/.openclaw/openclaw.json)
Key settings to preserve:
- -
gateway.port - Gateway port (default: 18788) - INLINECODE12 - Gateway authentication token
- INLINECODE13 - Feishu app credentials
- INLINECODE14 - API keys for AI models
Backup Contents
CODEBLOCK15
Important Notes
- 1. Always backup before uninstalling - Never skip the backup step
- Keep backup in a safe place - Copy to external storage or cloud
- Test after restore - Verify all configurations work correctly
- Third-party modifications - This procedure removes all third-party patches and returns to official version
- Memory files are preserved - The SQLite memory database is included in the backup
技能名称: reinstall-openclaw
详细描述:
重新安装 OpenClaw 技能
本技能提供完整流程,可在保留所有用户配置、凭据、记忆文件、技能和自定义设置的前提下,安全卸载并重新安装 OpenClaw。
使用场景
- - 通过全新安装修复损坏的 OpenClaw 安装
- 移除第三方修改,恢复至官方版本
- 通过全新安装升级至最新版本
- 将 OpenClaw 迁移至新环境并保留现有配置
前提条件
- - WSL(Ubuntu 20.04 或更高版本)或安装了 Node.js 的 Linux/macOS 系统
- Node.js 18+ 和 npm/pnpm
- 可访问 WSL 终端(Windows 用户)
完整流程
步骤 1:检查当前安装
首先,确认 OpenClaw 的安装位置和版本:
bash
检查 OpenClaw 版本
npx openclaw --version
查找 OpenClaw npm 包位置
npm root -g
列出全局 npm 包
npm list -g --depth=0
步骤 2:备份所有用户数据
创建所有用户配置的完整备份:
bash
创建带时间戳的备份目录
BACKUP_DIR=~/openclaw-backup-$(date +%Y%m%d)
mkdir -p $BACKUP_DIR
备份整个 .openclaw 目录
cp -r ~/.openclaw $BACKUP_DIR/
验证备份
ls -la $BACKUP_DIR/
需要备份的内容(已包含在 ~/.openclaw 中)
| 目录/文件 | 描述 |
|---|
| openclaw.json | 主配置文件(网关令牌、API 密钥、频道配置) |
| credentials/ |
API 凭据和密钥 |
| memory/ | SQLite 记忆数据库 |
| agents/ | 代理配置和会话 |
| skills/ | 已安装的技能 |
| workspace/ | 用户工作区(SOUL.md、IDENTITY.md、AGENTS.md 等) |
| feishu/ | 飞书配置 |
| identity/ | 设备身份文件 |
| devices/ | 已配对的设备 |
| cron/ | 定时任务 |
步骤 3:停止 OpenClaw 服务
停止所有正在运行的 OpenClaw 进程:
bash
如果网关正在运行,则停止
npx openclaw gateway stop
终止所有剩余进程
pkill -f openclaw
pkill -f node.*openclaw
确认没有进程在运行
ps aux | grep openclaw
步骤 4:卸载 OpenClaw
使用官方卸载命令:
bash
完全卸载(可选,会删除包括 CLI 在内的所有内容)
npx openclaw uninstall --all --yes
或卸载但保留 CLI(推荐)
npx openclaw uninstall --state --workspace --yes
注意:--all 标志会同时删除 CLI。如果您希望保留 CLI 以便重新安装,请省略此标志。
步骤 5:清理剩余文件
删除可能造成干扰的剩余文件:
bash
清除 npm 缓存(可选但推荐)
npm cache clean --force
如果旧版 OpenClaw npm 包仍存在,则删除
sudo npm uninstall -g openclaw
删除任何剩余的 .openclaw 目录
rm -rf ~/.openclaw
rm -rf ~/.openclaw-dev
步骤 6:安装最新版 OpenClaw
安装最新的官方版本:
bash
全局安装
sudo npm install -g openclaw@latest
验证安装
npx openclaw --version
步骤 7:恢复用户配置
恢复您备份的配置:
bash
恢复 .openclaw 目录
cp -r ~/openclaw-backup-YYYYMMDD/* ~/.openclaw/
设置正确的权限
chmod 700 ~/.openclaw
步骤 8:运行健康检查并修复
bash
运行诊断工具检查问题
npx openclaw doctor --fix
步骤 9:启动 OpenClaw 网关
bash
启动网关
npx openclaw gateway
检查健康状态
npx openclaw health
检查状态
npx openclaw status
完整的一键备份脚本
在卸载前运行此脚本以创建带时间戳的备份:
bash
创建自动备份
BACKUP
DIR=~/openclaw-backup-$(date +%Y%m%d-%H%M%S) && mkdir -p $BACKUPDIR && cp -r ~/.openclaw/* $BACKUP
DIR/ && echo 备份已创建:$BACKUPDIR
完整的一键恢复脚本
重新安装后运行此脚本以恢复配置:
bash
从最新备份恢复
LATEST
BACKUP=$(ls -td ~/openclaw-backup- | head -1) && cp -r $LATESTBACKUP/ ~/.openclaw/ && chmod 700 ~/.openclaw && echo 已从以下位置恢复:$LATEST_BACKUP
故障排除
恢复后网关无法启动
bash
停止所有过期进程
npx openclaw gateway stop
强制启动
npx openclaw gateway --force
端口已被占用
bash
查找使用该端口的进程
lsof -i :18788
终止该进程
kill
恢复后配置错误
bash
运行诊断工具修复
npx openclaw doctor --fix
权限问题
bash
修复 .openclaw 权限
chmod 700 ~/.openclaw
chmod 600 ~/.openclaw/openclaw.json
chmod 700 ~/.openclaw/credentials
文件参考
配置文件 (~/.openclaw/openclaw.json)
需要保留的关键设置:
- - gateway.port - 网关端口(默认:18788)
- gateway.auth.token - 网关认证令牌
- channels.feishu - 飞书应用凭据
- models.providers - AI 模型的 API 密钥
备份内容
~/.openclaw/
├── openclaw.json # 主配置文件
├── credentials/ # API 密钥
├── memory/main.sqlite # 记忆数据库
├── agents/main/ # 代理配置
├── skills/ # 已安装的技能
├── workspace/ # 用户工作区
│ ├── SOUL.md
│ ├── IDENTITY.md
│ ├── AGENTS.md
│ └── USER.md
├── feishu/ # 飞书配置
├── identity/ # 设备身份
├── devices/ # 已配对的设备
└── cron/ # 定时任务
重要说明
- 1. 卸载前务必备份 - 切勿跳过备份步骤
- 将备份保存在安全位置 - 复制到外部存储或云端
- 恢复后进行测试 - 验证所有配置是否正常工作
- 第三方修改 - 此流程会移除所有第三方补丁并恢复至官方版本
- 记忆文件得以保留 - SQLite 记忆数据库包含在备份中