@clawmover/cli 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +288 -0
- package/dist/index.js +21 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenClaw Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# @clawmover/cli
|
|
2
|
+
|
|
3
|
+
OpenClaw 数据备份和恢复命令行工具。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 🔄 **自动备份**: 将 OpenClaw 数据备份到远程服务器
|
|
8
|
+
- 📥 **数据恢复**: 从服务器快速恢复数据到本地
|
|
9
|
+
- 🔒 **数据加密**: 使用 data-secret-key 加密所有备份数据
|
|
10
|
+
- ⚡ **增量备份**: 基于 restic 的增量备份,节省存储空间
|
|
11
|
+
- 🏷️ **标签管理**: 使用标签组织和筛选备份
|
|
12
|
+
- ⚖️ **冲突处理**: 多种策略处理文件冲突
|
|
13
|
+
- 📊 **进度显示**: 实时显示备份和恢复进度
|
|
14
|
+
- 🔍 **详细日志**: 完整的操作日志记录
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @clawmover/cli
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
或从源码安装:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/clawmover/clawmover-cli.git
|
|
26
|
+
cd clawmover-cli
|
|
27
|
+
npm install
|
|
28
|
+
npm run build
|
|
29
|
+
npm link
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 配置
|
|
33
|
+
|
|
34
|
+
工具会自动读取 OpenClaw 配置文件,你也可以通过命令行参数覆盖:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# 查看配置文件路径
|
|
38
|
+
openclaw config file
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 使用方法
|
|
42
|
+
|
|
43
|
+
### 备份数据
|
|
44
|
+
|
|
45
|
+
基本备份命令:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
clawmover backup
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
指定实例 ID 和密钥:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
clawmover backup --instance-id your-instance-id --data-secret-key your-secret-key
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
高级选项:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
clawmover backup \
|
|
61
|
+
--instance-id your-instance-id \
|
|
62
|
+
--data-secret-key your-secret-key \
|
|
63
|
+
--tags production,daily \
|
|
64
|
+
--conflict-strategy smart \
|
|
65
|
+
--skip-temp \
|
|
66
|
+
--skip-cache \
|
|
67
|
+
--log-level debug
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**参数说明:**
|
|
71
|
+
|
|
72
|
+
- `--instance-id <id>`: 实例 ID (覆盖配置文件)
|
|
73
|
+
- `--data-secret-key <key>`: 数据密钥 (覆盖配置文件)
|
|
74
|
+
- `--tags <tags>`: 逗号分隔的标签列表
|
|
75
|
+
- `--conflict-strategy <strategy>`: 冲突处理策略 (smart|interactive|overwrite),默认: smart
|
|
76
|
+
- `--skip-temp`: 跳过临时文件
|
|
77
|
+
- `--skip-cache`: 跳过缓存文件
|
|
78
|
+
- `--storage-path <path>`: 自定义存储路径
|
|
79
|
+
- `--log-level <level>`: 日志级别 (debug|info|warn|error)
|
|
80
|
+
|
|
81
|
+
### 恢复数据
|
|
82
|
+
|
|
83
|
+
基本恢复命令:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
clawmover restore
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
指定快照 ID:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
clawmover restore --snapshot-id abc123
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
按标签筛选:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
clawmover restore --tags core,imessage-db
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
高级选项:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
clawmover restore \
|
|
105
|
+
--instance-id your-instance-id \
|
|
106
|
+
--data-secret-key your-secret-key \
|
|
107
|
+
--snapshot-id abc123 \
|
|
108
|
+
--tags core \
|
|
109
|
+
--conflict-strategy interactive \
|
|
110
|
+
--target-path /tmp/restore \
|
|
111
|
+
--log-level info
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**参数说明:**
|
|
115
|
+
|
|
116
|
+
- `--instance-id <id>`: 实例 ID (覆盖配置文件)
|
|
117
|
+
- `--data-secret-key <key>`: 数据密钥 (覆盖配置文件)
|
|
118
|
+
- `--snapshot-id <id>`: 要恢复的快照 ID (默认: 最新)
|
|
119
|
+
- `--tags <tags>`: 逗号分隔的标签,用于筛选快照
|
|
120
|
+
- `--conflict-strategy <strategy>`: 冲突处理策略 (smart|interactive|overwrite),默认: smart
|
|
121
|
+
- `--target-path <path>`: 恢复的目标目录
|
|
122
|
+
- `--log-level <level>`: 日志级别 (debug|info|warn|error)
|
|
123
|
+
|
|
124
|
+
## 冲突处理策略
|
|
125
|
+
|
|
126
|
+
### Smart (智能处理,推荐)
|
|
127
|
+
|
|
128
|
+
- **配置文件**: 询问用户如何处理
|
|
129
|
+
- **数据库**: 自动备份旧版本
|
|
130
|
+
- **附件**: 重命名本地文件
|
|
131
|
+
- **普通文件**: 比较修改时间,保留较新的
|
|
132
|
+
|
|
133
|
+
### Interactive (交互式处理)
|
|
134
|
+
|
|
135
|
+
每个冲突都会询问用户选择:
|
|
136
|
+
- 备份现有文件并覆盖
|
|
137
|
+
- 重命名现有文件
|
|
138
|
+
- 跳过此文件
|
|
139
|
+
- 直接覆盖
|
|
140
|
+
|
|
141
|
+
### Overwrite (自动覆盖)
|
|
142
|
+
|
|
143
|
+
直接覆盖所有冲突文件,不进行备份
|
|
144
|
+
|
|
145
|
+
## 备份计划
|
|
146
|
+
|
|
147
|
+
工具会自动生成备份计划,包含以下数据类型:
|
|
148
|
+
|
|
149
|
+
1. **Core 数据** (必需)
|
|
150
|
+
- OpenClaw 核心配置和数据
|
|
151
|
+
- 标签: `core`
|
|
152
|
+
|
|
153
|
+
2. **iMessage 数据库** (可选)
|
|
154
|
+
- 如果配置了 `imessageDb`
|
|
155
|
+
- 标签: `imessage-db`, `core`
|
|
156
|
+
|
|
157
|
+
3. **iMessage 附件** (可选)
|
|
158
|
+
- 如果配置了 `imessageAttachments`
|
|
159
|
+
- 标签: `imessage-attachments`, `core`
|
|
160
|
+
|
|
161
|
+
4. **Sandbox 数据** (可选)
|
|
162
|
+
- 沙箱环境数据
|
|
163
|
+
- 标签: `sandbox`
|
|
164
|
+
|
|
165
|
+
5. **缓存数据** (可选)
|
|
166
|
+
- 应用缓存
|
|
167
|
+
- 标签: `cache`
|
|
168
|
+
|
|
169
|
+
6. **临时文件** (可选)
|
|
170
|
+
- 临时文件
|
|
171
|
+
- 标签: `temp`
|
|
172
|
+
|
|
173
|
+
## 标签系统
|
|
174
|
+
|
|
175
|
+
使用标签可以更好地组织和筛选备份:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# 创建带标签的备份
|
|
179
|
+
clawmover backup --tags production,daily
|
|
180
|
+
|
|
181
|
+
# 恢复特定标签的数据
|
|
182
|
+
clawmover restore --tags production
|
|
183
|
+
|
|
184
|
+
# 查看特定实例的所有备份
|
|
185
|
+
clawmover list --instance-id your-instance-id
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
自动添加的标签:
|
|
189
|
+
- `instance:<instanceId>`: 实例 ID
|
|
190
|
+
- `date:<YYYY-MM-DD>`: 备份日期
|
|
191
|
+
|
|
192
|
+
## 日志和调试
|
|
193
|
+
|
|
194
|
+
设置日志级别:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# 详细调试信息
|
|
198
|
+
clawmover backup --log-level debug
|
|
199
|
+
|
|
200
|
+
# 只显示错误
|
|
201
|
+
clawmover backup --log-level error
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
日志文件默认保存在 `./logs/clawmover.log`。
|
|
205
|
+
|
|
206
|
+
## 开发
|
|
207
|
+
|
|
208
|
+
### 项目结构
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
@clawmover/cli/
|
|
212
|
+
├── src/
|
|
213
|
+
│ ├── commands/ # 命令执行层
|
|
214
|
+
│ ├── services/ # 核心服务层
|
|
215
|
+
│ ├── integrations/ # 外部集成层
|
|
216
|
+
│ ├── system/ # 系统服务层
|
|
217
|
+
│ ├── types/ # 类型定义
|
|
218
|
+
│ ├── utils/ # 工具函数
|
|
219
|
+
│ └── index.ts # 入口文件
|
|
220
|
+
├── tests/ # 测试文件
|
|
221
|
+
├── package.json
|
|
222
|
+
├── tsconfig.json
|
|
223
|
+
└── README.md
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 构建
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
npm run build
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### 测试
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# 运行所有测试
|
|
236
|
+
npm test
|
|
237
|
+
|
|
238
|
+
# 监视模式
|
|
239
|
+
npm run test:watch
|
|
240
|
+
|
|
241
|
+
# 覆盖率报告
|
|
242
|
+
npm run test:coverage
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### 代码质量
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# Lint
|
|
249
|
+
npm run lint
|
|
250
|
+
|
|
251
|
+
# 自动修复
|
|
252
|
+
npm run lint:fix
|
|
253
|
+
|
|
254
|
+
# 格式化代码
|
|
255
|
+
npm run format
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## 故障排除
|
|
259
|
+
|
|
260
|
+
### 备份失败
|
|
261
|
+
|
|
262
|
+
1. 检查网络连接
|
|
263
|
+
2. 验证 `data-secret-key` 是否正确
|
|
264
|
+
3. 查看日志文件获取详细错误信息
|
|
265
|
+
|
|
266
|
+
### 恢复失败
|
|
267
|
+
|
|
268
|
+
1. 确认快照 ID 存在
|
|
269
|
+
2. 检查目标目录权限
|
|
270
|
+
3. 验证 `data-secret-key` 是否与备份时相同
|
|
271
|
+
|
|
272
|
+
### 找不到 OpenClaw 配置
|
|
273
|
+
|
|
274
|
+
运行以下命令检查配置文件位置:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
openclaw config file
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## 许可证
|
|
281
|
+
|
|
282
|
+
MIT
|
|
283
|
+
|
|
284
|
+
## 支持
|
|
285
|
+
|
|
286
|
+
如有问题或建议,请访问:
|
|
287
|
+
- GitHub Issues: https://github.com/clawmover/clawmover-cli/issues
|
|
288
|
+
- 文档: https://github.com/clawmover/clawmover-cli#readme
|