闲碎记事本 闲碎记事本
首页
  • JAVA
  • Cloudflare
  • 学完再改一遍UI
友链
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

YAN

我要偷偷记录...
首页
  • JAVA
  • Cloudflare
  • 学完再改一遍UI
友链
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • java

  • linux

  • docker

  • redis

  • nginx

  • mysql

  • 其他

  • 环境搭建

  • Vibe Coding

    • Vibe Coding
    • MCP 协议说明与实现
    • MCP 使用
    • AI 引导与子任务
    • OpenClaw 迁移记录
      • 迁移步骤
        • ① 旧机器:停 gateway
        • ② 打包
        • ③ 传输
        • ④ 新机器:解压覆盖
        • ⑤ 修复权限(关键)
        • ⑥ 体检 + 重启
      • 一键脚本
      • 迁移后检查清单
  • Git

  • 知识库
  • Vibe Coding
YAN
2026-05-29
目录

OpenClaw 迁移记录

OpenClaw 的所有状态都在 ~/.openclaw 目录里——配置、会话、记忆、插件。换机器就是把这个目录搬过去,关键是停服务再打包,不然文件处于写入状态会损坏。

相关文档:OpenClaw (opens new window)

# 迁移步骤

# ① 旧机器:停 gateway

打包前必须停服务,保证文件一致性:

openclaw gateway stop

不停直接打包的风险:会话数据库、记忆文件正在写入,打包出来的可能是半成品,恢复后数据丢失。

# ② 打包

排除 logs 目录,减小体积:

cd ~ && tar -czf openclaw-state.tgz --exclude='.openclaw/logs' .openclaw

要看下包的大小是否正常:

ls -lh openclaw-state.tgz

# ③ 传输

rsync 或 scp 都行:

# scp
scp openclaw-state.tgz root@xx.xx.xx.xx:~/

# rsync(支持断点续传,大文件推荐)
rsync -avzP openclaw-state.tgz root@xx.xx.xx.xx:~/

# ④ 新机器:解压覆盖

先装好 openclaw,再解压:

cd ~ && tar -xzf openclaw-state.tgz

# ⑤ 修复权限(关键)

root 传输过来的文件属主可能不对,不修权限服务起不来:

chown -R $(whoami):$(whoami) ~/.openclaw

用 root 登录新机器时尤其注意这步——解压出来的文件属主是 root,但 openclaw 服务通常以普通用户跑。

# ⑥ 体检 + 重启

# 检查配置和依赖是否完整
openclaw doctor

# 重启 gateway
openclaw gateway restart

# 确认状态
openclaw status

doctor 报错就按提示修,别跳过直接启动。


# 一键脚本

把上面的步骤串起来,新机器装好 openclaw 后跑一次:

#!/bin/bash
# 新机器恢复脚本:解压 + 权限 + 体检 + 启动
set -e

cd ~
tar -xzf openclaw-state.tgz
chown -R $(whoami):$(whoami) ~/.openclaw
openclaw doctor
openclaw gateway restart
openclaw status

# 迁移后检查清单

# 配置完整
openclaw doctor

# 服务运行中
openclaw status

# 会话/记忆还在
ls ~/.openclaw/

# 日志无报错
tail -50 ~/.openclaw/logs/gateway.log
#OpenClaw#迁移#Linux
上次更新: 2026/08/18, 01:07:41
AI 引导与子任务
git使用

← AI 引导与子任务 git使用→

最近更新
01
Windows 和 Linux 环境下免密使用 SSH
08-11
02
Gradle 使用指南
05-29
03
Node.js 版本管理与环境隔离
05-29
更多文章>
Theme by Vdoing | Copyright © 2022-2026 YAN | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式