Files
EzVibeR/docs/usage/08-数据存储与备份.md
Claude Agent 205c57e9b7 Update: Usage
2026-06-20 14:55:47 +08:00

157 lines
5.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 08 · 数据存储与备份
## 1. 数据都存在哪
### 1.1 主配置
| 平台 | 路径 |
|---|---|
| Linux | `~/.live2D/live2d.conf.json` |
| macOS | `~/.live2D/live2d.conf.json` |
| Windows | `%USERPROFILE%\.live2D\live2d.conf.json` |
> ⚠️ **注意 Linux 大小写**:是 `.live2D`(大写 D不是 `.live2d`。代码写死。
文件大致结构(见 [03-首次启动配置.md §5](03-首次启动配置.md))。
### 1.2 会话数据
存在 Tauri 提供的**系统 app-data 目录**
| 平台 | 路径 |
|---|---|
| Linux | `~/.local/share/com.ezviber.plus/sessions/` |
| macOS | `~/Library/Application Support/com.ezviber.plus/sessions/` |
| Windows | `%APPDATA%\com.ezviber.plus\sessions\` |
子目录结构:
```
sessions/
├── _index.json ← 会话索引(标题/消息数/时间)
├── 2026-06-19_153500/ ← 会话 id = 创建时间戳
│ ├── chat.jsonl ← 消息流(一行一条 JSON
│ └── images/
│ ├── <uuid>.png ← 截图原图(给 LLM 多模态)
│ └── <uuid>.jpg ← 截图压缩预览(给聊天气泡)
├── 2026-06-19_180200/
│ ├── chat.jsonl
│ └── images/
└── __reminders__/ ← 提醒中心(特殊 id
├── chat.jsonl
└── images/ ← 一般为空
```
### 1.3 数据库
**`ezvibe_memory.db`**SQLite向量记忆
| 平台 | 路径 |
|---|---|
| 全部 | **`<工作目录>/ezvibe_memory.db`** ⚠️ |
> ⚠️ **坑**:这个路径是相对当前工作目录的,**不是 app-data 目录**。如果你用 `cd /tmp && /opt/ezviber-plus/live2d` 启动db 就会在 `/tmp/ezvibe_memory.db`。
>
> 实际影响不大——RAG embedder 是 `DummyEmbedder`,数据库几乎是空的。
### 1.4 模型缩放 / 位置
存在主配置的**每个 URL 下**(嵌套对象):
```jsonc
{
"https://...shizuku.model.json": {
"position": { "x": 100, "y": 200 },
"scale": { "x": 1.0, "y": 1.0 }
}
}
```
## 2. 数据迁移
搬家 / 换电脑 / 重装系统的标准流程:
```bash
# 1. 旧机器:备份
tar -czf ezviber-backup.tgz \
~/.live2D/ \
~/.local/share/com.ezviber.plus/ # Linux
# ~/Library/Application\ Support/com.ezviber.plus/ # macOS
# %APPDATA%\com.ezviber.plus\ # Windows
# 2. 同步到新机器
# 3. 新机器:解压到对应路径
tar -xzf ezviber-backup.tgz -C ~/
# 4. 装好 EzVibeR+ 之后启动一次
```
> ⚠️ **聊天里的图片用相对路径**`sessions/.../images/xxx.png`),所以**只要保证两台机器的 `app-data` 绝对路径一致**(如都在 `~/.local/share/com.ezviber.plus/`),图片就能正常显示。**改了用户名就坏**。
## 3. 启动时 GC自动清理
每次启动会**异步**跑一次图片孤儿 GC
1. 扫所有 `<app_data>/sessions/<id>/images/*.png|jpg|jpeg` → 候选集合 A
2. 扫所有 session 的 `chat.jsonl` → 引用集合 R只取 `imagePath` / `imagePngPath` 的文件名)
3. `A - R` = 孤儿
4. 删孤儿 + 打印日志
**保守策略**
- 单个 session 读 jsonl 失败 → 该 session 的所有图片**保留**(宁可漏删不误删)
- 只动 `.png / .jpg / .jpeg`,其他扩展名不动
- GC 失败只 `warn`,不阻断启动
日志格式(终端看):
```
启动 GC: 扫描 42 张,引用 35 张,删除 7 张孤儿,释放 1234567 字节
```
## 4. 删除某条消息 / 整个会话
- **整个会话**:聊天面板点 🗑 → 整个目录(含 jsonl 和 images都删
- **单条消息**:当前**不支持** UI 操作
- **绕过 UI 直接删**(高级):
- 删整个会话:删 `<app-data>/sessions/<id>/` 目录 + 手动编辑 `_index.json` 移除该条目
- 删某条消息:用文本编辑器打开 `chat.jsonl`,删对应行(保持一行一条 JSON 的格式)
- 改完**重启**软件让索引重读
## 5. 备份建议
| 频率 | 备份什么 | 工具 |
|---|---|---|
| 每周 | `~/.live2D/live2d.conf.json` | 任何同步盘 |
| 每次重要对话后 | 导出会话(`⬇ MD``⬇ JSON` | 内置导出 |
| 每月 | 整个 `app-data` 目录 | 任何备份工具 |
| 跨机器 | 同上 + 复制 `model_dir` | rsync / 同步盘 |
> 💡 **最稳的备份**是定期用「⬇ MD / ⬇ JSON」导出关键会话文件名自带时间戳和会话标题永久可读。
## 6. 隐私 & 安全
- 所有数据**只在本地**——不传给任何第三方
- LLM 调用按你配的 provider 走(你用哪家就是哪家,**没中间商**
- `live2d.conf.json` 里的 `llm_api_key` 是**明文**存盘的,注意文件权限
- Linux/macOS`chmod 600 ~/.live2D/live2d.conf.json`
- 截图保存在 `app-data/sessions/<id>/images/`**全屏内容都包括**——如果你截了敏感页面,记得手动删
## 7. 完全卸载
```bash
# Linux
rm -rf ~/.live2D/
rm -rf ~/.local/share/com.ezviber.plus/
# macOS
rm -rf ~/.live2D/
rm -rf ~/Library/Application\ Support/com.ezviber.plus/
rm -rf /Applications/EzVibeR+.app # 图形界面拖废纸篓也行
# Windows (PowerShell)
Remove-Item -Recurse -Force "$env:USERPROFILE\.live2D"
Remove-Item -Recurse -Force "$env:APPDATA\com.ezviber.plus"
```
---
下一步:[09-常见问题FAQ.md](09-常见问题FAQ.md)。