@xiaoyuyu6420/dsh-backup 0.7.0 → 0.7.2
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/README.md +30 -168
- package/README.zh.md +27 -147
- package/lib/client.js +6 -6
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -7,198 +7,60 @@
|
|
|
7
7
|
|
|
8
8
|
English | [简体中文](README.zh.md)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
settings, credentials, skills, and plugin config under `~/.dsh`, excluding
|
|
12
|
-
reinstallable `node_modules` — with sha256 checksums, integrity verification,
|
|
13
|
-
automatic rotation, and scheduled auto-backup that survives restarts.
|
|
14
|
-
**Credentials are redacted by default**: plaintext never enters an archive or
|
|
15
|
-
the GitHub sync, only a local vault, and is restored automatically. Cross-machine
|
|
16
|
-
restores get preflight hints and a one-command `github pull`. Works on macOS,
|
|
17
|
-
Linux, and Windows.
|
|
18
|
-
|
|
19
|
-
## Scenario cheat sheet
|
|
20
|
-
|
|
21
|
-
| Scenario | What to run |
|
|
22
|
-
|---|---|
|
|
23
|
-
| Everyday backup | `/backup` (or Settings → Plugins → Backup → Back up now) |
|
|
24
|
-
| Don't trust yourself to remember | `/backup auto 12` — scheduled, survives restarts |
|
|
25
|
-
| Broke a config / bad plugin install | `/backup restore latest --dry-run`, then drop the flag |
|
|
26
|
-
| `~/.dsh` is gone entirely | `/backup restore latest` — no existing data means no snapshot, straight to restore |
|
|
27
|
-
| New machine | Install the plugin, set the same `githubRepo` → `/backup github pull` → `/backup restore latest --sync-deps` |
|
|
28
|
-
| Suspect a corrupt archive | `/backup verify all` |
|
|
29
|
-
| Cloud copy | `/backup github repo name/dsh-backups` (private repo); every backup pushes afterwards |
|
|
30
|
-
|
|
31
|
-
## Commands
|
|
32
|
-
|
|
33
|
-
- **`/backup`** — immediately back up `~/.dsh` to `~/Desktop/dsh-backups/dsh-<timestamp>.tar.gz`
|
|
34
|
-
- **`/backup list`** — list existing backups (name + size) and auto-backup status
|
|
35
|
-
- **`/backup verify [prefix|all]`** — validate archive checksums (default: the newest)
|
|
36
|
-
- **`/backup restore <prefix|latest> [--dry-run] [--sync-deps]`** — restore `~/.dsh` from an archive (`--sync-deps` reinstalls per-profile plugin dependencies afterwards)
|
|
37
|
-
- **`/backup auto <N>|off|status`** — auto-backup every N hours (1–720; retains 3 copies below 24h, 7 otherwise, unless `config.keep` overrides; persisted across restarts)
|
|
38
|
-
- **`/backup --keep N`** — override the rotation count (default 7)
|
|
39
|
-
- **`/backup github status|sync|pull [--restore <prefix|latest>]|repo <address|off>`** — sync status / push now / pull backups from the repo / set the sync repository
|
|
40
|
-
- **`/backup delete|rm <prefix|latest>`** — delete a backup and its sidecars
|
|
41
|
-
- **`backup_dsh` tool** — same capability for the model (`mode=backup|list|verify|restore|auto`; restore accepts `syncDeps`)
|
|
42
|
-
|
|
43
|
-
## Credential redaction & the local vault
|
|
44
|
-
|
|
45
|
-
Credential files (by default `.credentials.yaml`, `.env`, `qq-bridge/config.json`;
|
|
46
|
-
extend or disable via `config.redact`) **never enter an archive**:
|
|
47
|
-
|
|
48
|
-
- On backup, plaintext copies are mirrored into `vault/` under the backup
|
|
49
|
-
directory (POSIX mode 700/600); archives and the GitHub sync carry only
|
|
50
|
-
redacted data.
|
|
51
|
-
- Restoring on the same machine copies the credentials back from the vault —
|
|
52
|
-
full fidelity.
|
|
53
|
-
- Restoring on a new machine (no vault) lists the missing credential files and
|
|
54
|
-
tells you to re-enter them.
|
|
55
|
-
- Each archive ships with `.redacted.json` (the redaction list) and
|
|
56
|
-
`.meta.json` (host / home / timestamp) sidecars; restore preflight uses them
|
|
57
|
-
to flag cross-machine path risks and credentials to re-enter.
|
|
58
|
-
- `config.redact: false` restores the v0.6.x plaintext behavior (not recommended).
|
|
59
|
-
|
|
60
|
-
## GitHub sync
|
|
61
|
-
|
|
62
|
-
With `config.githubRepo` set, every backup (manual, automatic, or panel) is
|
|
63
|
-
also pushed to a Git repository — archives, checksum sidecars, and rotation
|
|
64
|
-
deletions stay in sync:
|
|
65
|
-
|
|
66
|
-
```yaml
|
|
67
|
-
- id: dsh-backup
|
|
68
|
-
name: 'dsh-backup'
|
|
69
|
-
config:
|
|
70
|
-
githubRepo: 'your-name/dsh-backups' # owner/repo, full URL, or a local path
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Use a **private** repository — archives are redacted but still contain session
|
|
74
|
-
content. For an `https` remote, set the token in the environment
|
|
75
|
-
(`DSH_BACKUP_GITHUB_TOKEN` or `GITHUB_TOKEN`); it is only written into the sync
|
|
76
|
-
worktree's credential file (never process args). Push is `HEAD:main
|
|
77
|
-
--force-with-lease`; archives over 90 MB are skipped with a notice. State (last
|
|
78
|
-
push, last error) lives in `<destination>/auto.json` and shows in the panel and
|
|
79
|
-
`/backup github status`.
|
|
80
|
-
|
|
81
|
-
**Restoring on a new machine**: install the plugin, configure the same
|
|
82
|
-
`githubRepo`, then run `/backup github pull` — it fetches every remote backup
|
|
83
|
-
(each one sha256-verified; corrupt archives are skipped and reported), then
|
|
84
|
-
`/backup restore latest --sync-deps` restores and reinstalls plugin
|
|
85
|
-
dependencies. The restore report reads `.meta.json` to flag the cross-machine
|
|
86
|
-
restore (absolute-path risks) and lists the credentials to re-enter.
|
|
87
|
-
`--restore <prefix|latest>` restores a specific archive right after pulling.
|
|
88
|
-
|
|
89
|
-
## Settings panel (Web)
|
|
90
|
-
|
|
91
|
-
The same controls have a visual entry: a **Backup** tab inside Settings → Plugins
|
|
92
|
-
(`dsh web`). It shows the destination, auto-backup state, GitHub sync status, and
|
|
93
|
-
every archive with its size, and offers one-click back-up-now, per-archive
|
|
94
|
-
verify, download, restore with a dry-run preview plus explicit confirmation,
|
|
95
|
-
and **pull from GitHub** (the first step of a new-machine restore).
|
|
96
|
-
Downloads stream from the loopback-only route `GET /backup-download/<name>`.
|
|
97
|
-
The tab talks to the host through the `backupPanel` Typert Remote namespace
|
|
98
|
-
(`/api` RPC); the browser bundle ships prebuilt in `lib/client.js` — no build
|
|
99
|
-
step at install time.
|
|
100
|
-
|
|
101
|
-
## How restore works
|
|
102
|
-
|
|
103
|
-
Restore is safe by construction:
|
|
104
|
-
|
|
105
|
-
1. The archive's sha256 is verified first — a corrupt archive never touches existing data.
|
|
106
|
-
2. Entries are listed and any path outside the backup root rejects the restore (tar path-traversal guard).
|
|
107
|
-
3. Preflight: `.meta.json` flags a backup from another machine/home (absolute-path risks); redacted archives note that credentials come back from the local vault (or must be re-entered cross-machine).
|
|
108
|
-
4. The current `~/.dsh` is snapshotted, then moved aside to `~/.dsh.pre-restore-<timestamp>` — restore replaces rather than merges. A missing `~/.dsh` (data gone / first restore on a new machine) skips the snapshot and extracts directly.
|
|
109
|
-
5. The archive is extracted; redacted archives then restore credentials from the vault; `--sync-deps` runs `pnpm install` per profile (node_modules never travel inside archives).
|
|
110
|
-
6. Restart `dsh` afterwards so restored sessions and settings take effect.
|
|
111
|
-
|
|
112
|
-
`--dry-run` shows the archive summary and preflight hints without writing anything.
|
|
113
|
-
|
|
114
|
-
## Configuration (optional)
|
|
115
|
-
|
|
116
|
-
Plugin `config` in the active cordis profile:
|
|
117
|
-
|
|
118
|
-
```yaml
|
|
119
|
-
- id: dsh-backup
|
|
120
|
-
name: 'dsh-backup'
|
|
121
|
-
config:
|
|
122
|
-
destination: '~/Backups/dsh' # default ~/Desktop/dsh-backups
|
|
123
|
-
keep: 10 # manual rotation count (default 7); when set, also the auto-backup retention — auto keeps 3 copies below 24h, 7 otherwise by default
|
|
124
|
-
exclude: # extra tar --exclude patterns
|
|
125
|
-
- '*cache*'
|
|
126
|
-
redact: # extra redacted files (relative to ~/.dsh); false/'off' disables redaction
|
|
127
|
-
- 'some-plugin/token.json'
|
|
128
|
-
githubRepo: 'name/dsh-backups' # optional GitHub sync (see below)
|
|
129
|
-
```
|
|
10
|
+
**dsh-backup is a DeepSeek Harness (DSH) plugin that backs up and restores `~/.dsh` with a single command.**
|
|
130
11
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
## Security note
|
|
134
|
-
|
|
135
|
-
Credential files are redacted by default (see above): archives and the GitHub
|
|
136
|
-
sync carry no plaintext credentials — plaintext lives only in the local
|
|
137
|
-
`vault/` under the backup directory (POSIX 700/600). Archives may still contain
|
|
138
|
-
sensitive session content, so keep the sync repository private. Archives and
|
|
139
|
-
checksum sidecars are chmod 600 on POSIX (Windows relies on per-user profile
|
|
140
|
-
ACLs).
|
|
141
|
-
|
|
142
|
-
Storage note: the plugin writes its own data (archives, checksum sidecars,
|
|
143
|
-
`auto.json`, `vault/`) directly through `node:fs`, the same pattern as DSH's
|
|
144
|
-
own session persistence — the `ctx.fs` capability is the model-facing sandboxed
|
|
145
|
-
surface and does not apply to host-owned storage.
|
|
12
|
+
Sessions, settings, skills, and plugin config all live in `~/.dsh`. Delete it by accident, break a config, or move to a new machine — with a backup, you get it all back. Credentials never enter an archive; scheduled backups and GitHub sync are supported (details in the [advanced guide](docs/advanced.zh.md), Chinese).
|
|
146
13
|
|
|
147
14
|
## Install
|
|
148
15
|
|
|
149
16
|
```sh
|
|
150
17
|
dsh plugin --profile web add @xiaoyuyu6420/dsh-backup
|
|
151
|
-
# or from
|
|
18
|
+
# or from GitHub:
|
|
152
19
|
dsh plugin --profile web add github:xiaoyuyu6420/dsh-backup
|
|
153
20
|
```
|
|
154
21
|
|
|
155
|
-
|
|
156
|
-
> unscoped `dsh-backup` on npm is an unrelated third-party package — don't
|
|
157
|
-
> install it.
|
|
22
|
+
Then restart `dsh web`. Requires macOS / Linux / Windows 10+ (ships `tar`) and DSH `0.1.0-rc.6` or compatible.
|
|
158
23
|
|
|
159
24
|
## Quickstart
|
|
160
25
|
|
|
161
|
-
|
|
26
|
+
1. Install (above) and restart `dsh web`
|
|
27
|
+
2. Run `/backup`
|
|
28
|
+
3. Done — the archive lands in `~/Desktop/dsh-backups/`, named with a timestamp
|
|
162
29
|
|
|
163
|
-
|
|
164
|
-
2. Restart `dsh web` — plugin discovery is cached per process.
|
|
165
|
-
3. Run `/backup` — the archive and its sha256 sidecar land in `~/Desktop/dsh-backups/`.
|
|
30
|
+
Want it on a schedule? `/backup auto 12` — every 12 hours, keeps going across restarts.
|
|
166
31
|
|
|
167
|
-
|
|
32
|
+
## Commands
|
|
168
33
|
|
|
169
|
-
|
|
34
|
+
| Task | Command |
|
|
35
|
+
|---|---|
|
|
36
|
+
| Back up now | `/backup` |
|
|
37
|
+
| Schedule | `/backup auto 12` (`off` to stop, `status` to check) |
|
|
38
|
+
| Restore | `/backup restore latest` (`--dry-run` to preview) |
|
|
39
|
+
| List backups | `/backup list` |
|
|
40
|
+
| Verify integrity | `/backup verify [prefix\|all]` |
|
|
41
|
+
| Delete | `/backup delete <prefix\|latest>` |
|
|
42
|
+
| Keep N copies (default 7) | `/backup --keep N` |
|
|
170
43
|
|
|
171
|
-
|
|
172
|
-
System32; Git Bash's GNU tar also works — checksums prefer `sha256sum`/`shasum`
|
|
173
|
-
and fall back to an in-process hash on Windows)
|
|
174
|
-
- DSH `0.1.0-rc.6` or compatible
|
|
44
|
+
Prefer clicking? There's a visual panel in `dsh web` settings.
|
|
175
45
|
|
|
176
|
-
##
|
|
46
|
+
## New machine
|
|
177
47
|
|
|
178
|
-
|
|
179
|
-
- **Which `tar` on Windows?** Either one works — Windows ships bsdtar in System32, and Git Bash provides GNU tar. Checksums prefer `sha256sum`/`shasum` when present and fall back to an in-process hash, so `/backup verify` works in both shells.
|
|
180
|
-
- **Installed the wrong package** — the npm package is the **scoped** `@xiaoyuyu6420/dsh-backup`; the unscoped `dsh-backup` is an unrelated third-party package. Check your profile's plugin list and reinstall with the scoped name.
|
|
48
|
+
Prerequisite: GitHub sync was configured on the old one ([setup](docs/advanced.zh.md#github-同步可选)).
|
|
181
49
|
|
|
182
|
-
|
|
50
|
+
1. Install the plugin, set the same `githubRepo`
|
|
51
|
+
2. `/backup github pull` — fetch the remote backups
|
|
52
|
+
3. `/backup restore latest --sync-deps` — restore and reinstall plugin dependencies
|
|
53
|
+
4. Restart `dsh`
|
|
183
54
|
|
|
184
|
-
|
|
185
|
-
lives in `src/` and is bundled (zod inlined, React/Cordis external) into
|
|
186
|
-
`lib/client.js`, which is committed so git installs never build:
|
|
55
|
+
## More
|
|
187
56
|
|
|
188
|
-
|
|
189
|
-
node scripts/build-client.mjs # rebuild the client bundle after editing src/
|
|
190
|
-
node scripts/smoke.mjs # host smoke suite (real temp dir, mocked DSH services)
|
|
191
|
-
node scripts/smoke-client.mjs # client bundle: handshake, schemas, tab registration, SSR
|
|
192
|
-
```
|
|
57
|
+
Retention policy, credential redaction, GitHub sync, restore safeguards, config reference, troubleshooting, and development notes — in the [advanced guide](docs/advanced.zh.md) (Chinese).
|
|
193
58
|
|
|
194
59
|
## Acknowledgements
|
|
195
60
|
|
|
196
|
-
- [@beastrobin](https://github.com/beastrobin) — the reserved-method-name root
|
|
197
|
-
|
|
198
|
-
- [@
|
|
199
|
-
cause report in #2
|
|
200
|
-
- [@Choi-Peng](https://github.com/Choi-Peng) — triage help pointing affected
|
|
201
|
-
users to the fix in #5
|
|
61
|
+
- [@beastrobin](https://github.com/beastrobin) — the reserved-method-name root cause analysis in #1 that directly led to the v0.5.1 fix
|
|
62
|
+
- [@mlosun](https://github.com/mlosun) — the thorough reproduction and root cause report in #2
|
|
63
|
+
- [@Choi-Peng](https://github.com/Choi-Peng) — triage help pointing affected users to the fix in #5
|
|
202
64
|
|
|
203
65
|
## License
|
|
204
66
|
|
package/README.zh.md
CHANGED
|
@@ -7,174 +7,54 @@
|
|
|
7
7
|
|
|
8
8
|
[English](README.md) | 简体中文
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
技能与插件配置(排除可重装的 node_modules),自动生成 sha256 校验和、完整性
|
|
12
|
-
校验、自动轮换,定时自动备份状态落盘、重启续跑。**凭据默认脱敏**:明文绝不
|
|
13
|
-
进归档、不进 GitHub 同步,只存本机 vault,恢复时自动还原。跨机恢复有预检
|
|
14
|
-
提示与 `github pull` 一键拉取。支持 macOS / Linux / Windows。
|
|
10
|
+
**dsh-backup 是 DeepSeek Harness(DSH)的备份插件:一条命令备份 `~/.dsh`,一条命令恢复。**
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| 场景 | 怎么做 |
|
|
19
|
-
|---|---|
|
|
20
|
-
| 日常备份 | `/backup`(或 Settings → Plugins → 备份 → 立即备份) |
|
|
21
|
-
| 担心忘备份 | `/backup auto 12` —— 定时备份,重启续跑 |
|
|
22
|
-
| 改坏了配置/装坏了插件 | `/backup restore latest --dry-run` 预览确认后去掉 `--dry-run` |
|
|
23
|
-
| `~/.dsh` 整个没了 | `/backup restore latest` —— 无现有数据时跳过快照直接恢复 |
|
|
24
|
-
| 换新电脑 | 新机装好插件并配置同一 `githubRepo` → `/backup github pull` 拉回备份 → `/backup restore latest --sync-deps` |
|
|
25
|
-
| 怀疑备份损坏 | `/backup verify all` |
|
|
26
|
-
| 归档同步到云端 | `/backup github repo 账号/dsh-backups`(私有仓库),此后每次备份自动推送 |
|
|
27
|
-
|
|
28
|
-
## 命令
|
|
29
|
-
|
|
30
|
-
- **`/backup`** —— 立即备份 `~/.dsh` 到 `~/Desktop/dsh-backups/dsh-<时间戳>.tar.gz`
|
|
31
|
-
- **`/backup list`** —— 列出已有备份(名称 + 大小)与自动备份状态
|
|
32
|
-
- **`/backup verify [前缀|all]`** —— 校验归档完整性(缺省校验最新一份)
|
|
33
|
-
- **`/backup restore <前缀|latest> [--dry-run] [--sync-deps]`** —— 从归档恢复 `~/.dsh`(`--sync-deps` 恢复后对各 profile 重装插件依赖)
|
|
34
|
-
- **`/backup auto <N小时>|off|status`** —— 每 N 小时自动备份(1~720;保留份数默认 <24h 3 份、否则 7 份,config.keep 可覆盖;状态持久化,重启续跑)
|
|
35
|
-
- **`/backup --keep N`** —— 覆盖轮换保留份数(默认 7)
|
|
36
|
-
- **`/backup github status|sync|pull [--restore <前缀|latest>]|repo <地址|off>`** —— 同步状态 / 立即推送 / 从仓库拉取备份到本地 / 设置同步仓库
|
|
37
|
-
- **`/backup delete|rm <前缀|latest>`** —— 删除指定备份(归档 + 全部边车)
|
|
38
|
-
- **`backup_dsh` 工具** —— 模型可调用同一能力(`mode=backup|list|verify|restore|auto`,restore 支持 `syncDeps`)
|
|
39
|
-
|
|
40
|
-
## 凭据脱敏与本机 vault
|
|
41
|
-
|
|
42
|
-
凭据文件(默认 `.credentials.yaml`、`.env`、`qq-bridge/config.json`,
|
|
43
|
-
`config.redact` 可增删)**不进归档**:
|
|
44
|
-
|
|
45
|
-
- 备份时,敏感文件的明文副本镜像到备份目录下的 `vault/`(POSIX 上目录 700、
|
|
46
|
-
文件 600),归档与 GitHub 同步只含脱敏后的数据。
|
|
47
|
-
- 本机恢复时,凭据自动从 vault 拷回 `~/.dsh`,完整还原。
|
|
48
|
-
- 跨机恢复(新机没有 vault)时,恢复报告会列出缺失的凭据文件清单,提示重填。
|
|
49
|
-
- 归档附带的 `.redacted.json`(脱敏清单)与 `.meta.json`(主机/家目录/时间)
|
|
50
|
-
边车随归档走,恢复预检据此提示跨机路径风险与需重填的凭据。
|
|
51
|
-
- `config.redact: false` 可回到 v0.6.x 的明文行为(不推荐)。
|
|
52
|
-
|
|
53
|
-
## GitHub 同步
|
|
54
|
-
|
|
55
|
-
配置 `config.githubRepo` 后,每次备份(手动 / 定时 / 面板)都会把归档、校验
|
|
56
|
-
边车与轮换删除一并推送到 Git 仓库:
|
|
57
|
-
|
|
58
|
-
```yaml
|
|
59
|
-
- id: dsh-backup
|
|
60
|
-
name: 'dsh-backup'
|
|
61
|
-
config:
|
|
62
|
-
githubRepo: '你的账号/dsh-backups' # owner/repo、完整 URL 或本地路径
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
**请使用私有仓库**——归档虽已脱敏,但仍含会话内容等敏感数据。https 远端需要
|
|
66
|
-
环境变量 token(`DSH_BACKUP_GITHUB_TOKEN` 或 `GITHUB_TOKEN`),token 只写入
|
|
67
|
-
同步工作树的 credential 文件(不进进程参数)。推送为 `HEAD:main
|
|
68
|
-
--force-with-lease`;超过 90MB 的归档会跳过并提示。同步状态(上次推送 / 错误)
|
|
69
|
-
存于 `<destination>/auto.json`,面板与 `/backup github status` 可见。
|
|
70
|
-
|
|
71
|
-
**换新机器恢复**:新机装好插件、配好同一 `githubRepo` 后执行
|
|
72
|
-
`/backup github pull` —— 拉回远端全部备份(逐份 sha256 校验,损坏即跳过并
|
|
73
|
-
报告),再 `/backup restore latest --sync-deps` 恢复并重装插件依赖;恢复报告
|
|
74
|
-
会按 `.meta.json` 提示这是跨机恢复(绝对路径风险)并列出需重填的凭据清单。
|
|
75
|
-
加 `--restore <前缀|latest>` 可在拉取后直接恢复指定备份。
|
|
76
|
-
|
|
77
|
-
## Settings 可视面板(Web)
|
|
78
|
-
|
|
79
|
-
同样的能力在 `dsh web` 的 **Settings → Plugins → 备份** 标签页有可视化入口:
|
|
80
|
-
显示备份目录、自动备份状态、GitHub 同步状态和每份归档的大小,支持一键立即
|
|
81
|
-
备份、逐份校验、**下载**、带 dry-run 预览与二次确认的恢复,以及**从 GitHub
|
|
82
|
-
拉取**备份(新机恢复第一步)。下载走仅限本机的
|
|
83
|
-
`GET /backup-download/<归档名>` 路由。面板经 `backupPanel` Typert Remote
|
|
84
|
-
命名空间(`/api` RPC)与宿主通信;浏览器 bundle 预构建在 `lib/client.js`,
|
|
85
|
-
安装时无需构建。
|
|
86
|
-
|
|
87
|
-
## 恢复的工作方式
|
|
88
|
-
|
|
89
|
-
恢复安全性是设计出来的:
|
|
90
|
-
|
|
91
|
-
1. 先校验归档 sha256——损坏的归档绝不触碰现有数据。
|
|
92
|
-
2. 列出归档条目,任何超出备份根目录的路径都会拒绝恢复(tar 路径穿越防护)。
|
|
93
|
-
3. 预检:`.meta.json` 显示备份来自另一台机器/用户目录时提示绝对路径风险;
|
|
94
|
-
脱敏归档提示凭据将从本机 vault 还原(跨机则提示重填)。
|
|
95
|
-
4. 当前 `~/.dsh` 先自动快照,再移动到 `~/.dsh.pre-restore-<时间戳>`——恢复是
|
|
96
|
-
替换而不是合并;`~/.dsh` 已不存在(数据全失/新机首恢复)时跳过快照直接解压。
|
|
97
|
-
5. 解压归档;脱敏归档随后从 vault 还原凭据文件;`--sync-deps` 对各 profile
|
|
98
|
-
执行 `pnpm install` 重装插件依赖(node_modules 不随归档走)。
|
|
99
|
-
6. 重启 `dsh`,恢复的会话与配置即生效。
|
|
100
|
-
|
|
101
|
-
`--dry-run` 只显示归档概要与预检提示,不写入任何内容。
|
|
102
|
-
|
|
103
|
-
## 配置(可选)
|
|
104
|
-
|
|
105
|
-
在生效的 cordis profile 中为插件声明 `config`:
|
|
106
|
-
|
|
107
|
-
```yaml
|
|
108
|
-
- id: dsh-backup
|
|
109
|
-
name: 'dsh-backup'
|
|
110
|
-
config:
|
|
111
|
-
destination: '~/Backups/dsh' # 默认 ~/Desktop/dsh-backups
|
|
112
|
-
keep: 10 # 手动备份轮换份数(默认 7);配置后同时作为自动备份保留份数(未配置时 auto 默认 <24h 3 份 / 否则 7 份)
|
|
113
|
-
exclude: # 额外的 tar --exclude 模式
|
|
114
|
-
- '*cache*'
|
|
115
|
-
redact: # 追加脱敏文件(相对 ~/.dsh);false/'off' 关闭脱敏
|
|
116
|
-
- 'some-plugin/token.json'
|
|
117
|
-
githubRepo: '账号/dsh-backups' # 可选 GitHub 同步(见下文)
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
自动备份状态保存在 `<destination>/auto.json`,重启后按上次自动执行时间推算下次触发(不重置节奏)。
|
|
121
|
-
|
|
122
|
-
## 安全说明
|
|
123
|
-
|
|
124
|
-
凭据文件默认脱敏(见上文「凭据脱敏与本机 vault」):归档与 GitHub 同步不含
|
|
125
|
-
明文凭据,明文只存备份目录下的本机 `vault/`(POSIX 700/600)。归档仍可能含
|
|
126
|
-
会话中的敏感内容,请使用私有同步仓库。归档与校验文件在 POSIX 上为
|
|
127
|
-
`chmod 600`(Windows 依赖用户目录 ACL)。
|
|
128
|
-
|
|
129
|
-
存储说明:插件自有数据(归档、校验和、`auto.json`、`vault/`)直接经
|
|
130
|
-
`node:fs` 写入,与 DSH 自身的会话持久化同一模式——`ctx.fs` 能力是模型面的
|
|
131
|
-
沙箱 surface,不适用于宿主插件的自有存储。
|
|
12
|
+
会话记录、设置、技能、插件配置全在 `~/.dsh` 一个目录里。误删了、改坏了、换电脑了——有备份就能找回来。密码等敏感文件不进备份包,还支持定时自动备份和 GitHub 云同步(细节见[进阶文档](docs/advanced.zh.md))。
|
|
132
13
|
|
|
133
14
|
## 安装
|
|
134
15
|
|
|
135
16
|
```sh
|
|
136
17
|
dsh plugin --profile web add @xiaoyuyu6420/dsh-backup
|
|
137
|
-
#
|
|
18
|
+
# 或者从 GitHub 安装:
|
|
138
19
|
dsh plugin --profile web add github:xiaoyuyu6420/dsh-backup
|
|
139
20
|
```
|
|
140
21
|
|
|
141
|
-
|
|
142
|
-
> 的 `dsh-backup` 是无关的第三方包,请勿安装。
|
|
22
|
+
装完重启 `dsh web`。要求:macOS / Linux / Windows 10+(自带 `tar`),DSH `0.1.0-rc.6` 或兼容版本。
|
|
143
23
|
|
|
144
24
|
## 快速上手
|
|
145
25
|
|
|
146
|
-
|
|
26
|
+
1. 按上面装好插件,重启 `dsh web`
|
|
27
|
+
2. 输入 `/backup`
|
|
28
|
+
3. 搞定 —— 备份出现在 `~/Desktop/dsh-backups/`,文件名带时间戳
|
|
147
29
|
|
|
148
|
-
|
|
149
|
-
2. 重启 `dsh web` —— 插件发现按进程缓存。
|
|
150
|
-
3. 跑 `/backup` —— 归档连同 sha256 校验文件落到 `~/Desktop/dsh-backups/`。
|
|
30
|
+
想定时自动跑?`/backup auto 12`(每 12 小时一次,重启不中断)。
|
|
151
31
|
|
|
152
|
-
|
|
32
|
+
## 命令速查
|
|
153
33
|
|
|
154
|
-
|
|
34
|
+
| 场景 | 命令 |
|
|
35
|
+
|---|---|
|
|
36
|
+
| 立即备份 | `/backup` |
|
|
37
|
+
| 定时备份 | `/backup auto 12`(`off` 关闭,`status` 看状态) |
|
|
38
|
+
| 恢复 | `/backup restore latest`(`--dry-run` 先预览) |
|
|
39
|
+
| 列出备份 | `/backup list` |
|
|
40
|
+
| 校验是否完好 | `/backup verify [前缀\|all]` |
|
|
41
|
+
| 删除某份备份 | `/backup delete <前缀\|latest>` |
|
|
42
|
+
| 保留份数(默认 7) | `/backup --keep N` |
|
|
155
43
|
|
|
156
|
-
|
|
157
|
-
bsdtar,Git Bash 的 GNU tar 也可以;校验和优先 `sha256sum`/`shasum`,
|
|
158
|
-
Windows 上回退进程内哈希)
|
|
159
|
-
- DSH `0.1.0-rc.6` 或兼容版本
|
|
44
|
+
不想敲命令?`dsh web` 设置里有可视化面板。
|
|
160
45
|
|
|
161
|
-
##
|
|
46
|
+
## 换新电脑
|
|
162
47
|
|
|
163
|
-
|
|
164
|
-
- **Windows 上用哪个 `tar`?** 都可以——Windows 自带 System32 里的 bsdtar,Git Bash 里则是 GNU tar。校验和优先用 `sha256sum`/`shasum`,缺失时自动回退进程内哈希,两种 shell 下 `/backup verify` 都能正常工作。
|
|
165
|
-
- **装错了包** —— npm 包名是 **scoped** 的 `@xiaoyuyu6420/dsh-backup`;不带 scope 的 `dsh-backup` 是无关的第三方包。检查 profile 的插件列表,改用 scoped 名重装。
|
|
48
|
+
前提:旧电脑配过 GitHub 同步([配置方法](docs/advanced.zh.md#github-同步可选))。
|
|
166
49
|
|
|
167
|
-
|
|
50
|
+
1. 新电脑装好插件,配置里填同一个 `githubRepo`
|
|
51
|
+
2. `/backup github pull` —— 拉回云端备份
|
|
52
|
+
3. `/backup restore latest --sync-deps` —— 恢复并重装插件依赖
|
|
53
|
+
4. 重启 `dsh`
|
|
168
54
|
|
|
169
|
-
|
|
170
|
-
打包(zod 内联、React/Cordis 保持 external)产物 `lib/client.js` 提交进仓库,
|
|
171
|
-
git 安装无需构建:
|
|
55
|
+
## 更多
|
|
172
56
|
|
|
173
|
-
|
|
174
|
-
node scripts/build-client.mjs # 改 src/ 后重新打包客户端
|
|
175
|
-
node scripts/smoke.mjs # 宿主冒烟(真实临时目录 + 模拟 DSH 服务)
|
|
176
|
-
node scripts/smoke-client.mjs # 客户端 bundle:握手/schema/标签页注册/SSR
|
|
177
|
-
```
|
|
57
|
+
定时备份策略、敏感文件脱敏、GitHub 同步、恢复的保护机制、配置参考、故障排查、开发说明——都在[进阶文档](docs/advanced.zh.md)。
|
|
178
58
|
|
|
179
59
|
## 致谢
|
|
180
60
|
|