mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-21 22:27:13 +08:00
feat(cli): add portable data backup and restore
This commit is contained in:
51
docs/cli/backup.mdx
Normal file
51
docs/cli/backup.mdx
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: Backup and Restore
|
||||
description: Export and restore CowAgent configuration and agent workspace data
|
||||
---
|
||||
|
||||
CowAgent can create a portable local archive for migration or disaster recovery.
|
||||
|
||||
## Create a backup
|
||||
|
||||
```bash
|
||||
cow backup
|
||||
cow backup --output /safe/location/cow-backup.zip
|
||||
```
|
||||
|
||||
The archive contains:
|
||||
|
||||
- `config.json`
|
||||
- Agent persona and user files such as `AGENT.md`, `USER.md`, and `MEMORY.md`
|
||||
- Daily memory, session history, knowledge, custom skills, and scheduled tasks in the configured workspace
|
||||
- Legacy `user_datas.pkl`, when present
|
||||
|
||||
Transient `tmp/` data, caches, Git metadata, and symbolic links are skipped. The
|
||||
archive is written with owner-only permissions where the operating system
|
||||
supports them.
|
||||
|
||||
<Warning>
|
||||
A backup may contain API keys, conversation history, and other personal data.
|
||||
Store and transfer it as a secret. The ZIP file is not encrypted.
|
||||
</Warning>
|
||||
|
||||
## Restore a backup
|
||||
|
||||
Stop CowAgent before restoring:
|
||||
|
||||
```bash
|
||||
cow stop
|
||||
cow restore /safe/location/cow-backup.zip
|
||||
```
|
||||
|
||||
Use `--workspace` to migrate workspace files to a different location:
|
||||
|
||||
```bash
|
||||
cow restore cow-backup.zip --workspace ~/cow-restored
|
||||
```
|
||||
|
||||
Restore validates the archive format and paths before writing anything. It
|
||||
overwrites matching files but does not delete unrelated files already present
|
||||
at the destination. When current CowAgent data exists, the command first
|
||||
creates a `cow-pre-restore-*.zip` rollback archive beside the selected backup.
|
||||
|
||||
For unattended scripts, pass `--yes` to acknowledge overwrites.
|
||||
@@ -44,6 +44,10 @@ Memory & Knowledge:
|
||||
memory Memory distillation (dream)
|
||||
knowledge View knowledge base stats and structure
|
||||
|
||||
Data portability:
|
||||
backup Back up config and agent workspace
|
||||
restore Restore a CowAgent backup
|
||||
|
||||
Others:
|
||||
help Show this help message
|
||||
version Show version
|
||||
@@ -90,6 +94,7 @@ In the Web console or any connected channel, type `/` to see command suggestions
|
||||
| start / stop / restart | ✓ | ✗ |
|
||||
| update | ✓ | ✗ |
|
||||
| install-browser | ✓ | ✗ |
|
||||
| backup / restore | ✓ | ✗ |
|
||||
|
||||
<Note>
|
||||
`context` only shows a hint in the terminal to use it in chat. `config` is only available in chat.
|
||||
|
||||
@@ -246,6 +246,7 @@
|
||||
"cli/process",
|
||||
"cli/skill",
|
||||
"cli/memory-knowledge",
|
||||
"cli/backup",
|
||||
"cli/general"
|
||||
]
|
||||
}
|
||||
@@ -473,6 +474,7 @@
|
||||
"zh/cli/process",
|
||||
"zh/cli/skill",
|
||||
"zh/cli/memory-knowledge",
|
||||
"zh/cli/backup",
|
||||
"zh/cli/general"
|
||||
]
|
||||
}
|
||||
|
||||
45
docs/zh/cli/backup.mdx
Normal file
45
docs/zh/cli/backup.mdx
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
title: 备份与恢复
|
||||
description: 导出和恢复 CowAgent 配置及 Agent 工作区数据
|
||||
---
|
||||
|
||||
CowAgent 可以生成便携的本地归档,用于设备迁移或灾难恢复。
|
||||
|
||||
## 创建备份
|
||||
|
||||
```bash
|
||||
cow backup
|
||||
cow backup --output /safe/location/cow-backup.zip
|
||||
```
|
||||
|
||||
归档包含:
|
||||
|
||||
- `config.json`
|
||||
- `AGENT.md`、`USER.md`、`MEMORY.md` 等 Agent 人格和用户文件
|
||||
- 工作区内的每日记忆、会话历史、知识库、自定义技能和定时任务
|
||||
- 旧版 `user_datas.pkl`(如存在)
|
||||
|
||||
临时 `tmp/` 数据、缓存、Git 元数据和符号链接不会写入归档。在操作系统支持的情况下,归档文件权限会限制为仅当前用户可读写。
|
||||
|
||||
<Warning>
|
||||
备份中可能含有 API 密钥、对话历史及其他个人数据,应按密钥文件保存和传输。ZIP 文件本身没有加密。
|
||||
</Warning>
|
||||
|
||||
## 恢复备份
|
||||
|
||||
恢复前先停止 CowAgent:
|
||||
|
||||
```bash
|
||||
cow stop
|
||||
cow restore /safe/location/cow-backup.zip
|
||||
```
|
||||
|
||||
迁移到不同工作区时,可以显式指定路径:
|
||||
|
||||
```bash
|
||||
cow restore cow-backup.zip --workspace ~/cow-restored
|
||||
```
|
||||
|
||||
恢复命令会在写入前校验归档格式和所有路径。它会覆盖同名文件,但不会删除目标目录中无关的现有文件。如果检测到当前 CowAgent 数据,会先在所选归档旁创建 `cow-pre-restore-*.zip` 回滚备份。
|
||||
|
||||
无人值守脚本可传入 `--yes` 确认覆盖。
|
||||
@@ -44,6 +44,10 @@ Memory & Knowledge:
|
||||
memory Memory distillation (dream)
|
||||
knowledge View knowledge base stats and structure
|
||||
|
||||
Data portability:
|
||||
backup Back up config and agent workspace
|
||||
restore Restore a CowAgent backup
|
||||
|
||||
Others:
|
||||
help Show this help message
|
||||
version Show version
|
||||
@@ -92,6 +96,7 @@ Others:
|
||||
| start / stop / restart | ✓ | ✗ |
|
||||
| update | ✓ | ✗ |
|
||||
| install-browser | ✓ | ✗ |
|
||||
| backup / restore | ✓ | ✗ |
|
||||
|
||||
<Note>
|
||||
`context` 在终端中仅提示到对话中使用。`config` 仅支持在对话中修改。
|
||||
|
||||
Reference in New Issue
Block a user