- Home
- Plugins
- Tools & Capabilities
- dsh-baidu-backup
dsh-baidu-backup
smazinge/dsh-baidu-backup
Incremental backup of the DSH home directory (.dsh) and a chosen workspace folder to your own Baidu Netdisk: manually, as a dry run, or on a schedule, with a settings page. Users bring their own Baidu Open Platform AppKey and authorize their own account; no shared application credentials are bundled. The folder picker is Windows-only. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.
Install
dsh plugin --profile web add github:smazinge/dsh-baidu-backupREADME
Baidu Netdisk backup · 百度网盘备份
Back up DeepSeek Harness ($DSH_HOME) and its workspace to your own Baidu Netdisk account. The package ID is dsh-baidu-backup.
Nothing is shared between installations: this plugin bundles no app key and no account. Each user creates their own Baidu Open Platform app, pastes its AppKey / SecretKey into the settings page, and authorizes their own account. Credentials and tokens stay on the local machine.
New here? Read docs/APP-SETUP.md — a step-by-step Chinese walkthrough (plus an English TL;DR) of getting an AppKey, choosing the app purpose, the quota limits, and the API list you need if you ever submit a release review.
项目位置与版本 / Where this lives 本地维护目录是
H:\DSH\space\项目\百度网盘自动备份插件,工作副本就在该目录根部(DSH 的 profile 用link:指向它)。 每更新一次,跑scripts\new-version.ps1生成新版本号 +versions\v<版本>-<日期>\快照;规则见 docs/VERSIONING.md,历史见 CHANGELOG.md。
Step 0 — create your own Baidu app (once per install)
Baidu's OAuth requires an application identity, and only you can create it. It is free and takes about 3–5 minutes. The same six steps are built into the settings page (collapsed by default), so the person installing the plugin never has to leave DSH to find out how. Full walkthrough with quota table, error codes and a copy-paste API list for the release review: docs/APP-SETUP.md.
Short version:
- Sign in at https://pan.baidu.com/union with the Baidu account you want to back up to — app, netdisk and authorization then all live under one account.
- Open the console https://pan.baidu.com/union/console/applist. The first visit asks for a free developer verification (real-name Baidu account + bound email). An individual developer can create one app.
- 创建应用 / Create app → type 软件 / 应用 (Software / App), any name, any matching category.
- Pick the 应用用途 / app purpose — this decides whether a review is needed:
- 个人使用 / Personal use → immediately usable, no review, but at most 10 authorized users.
- 公开发布使用 / Public release → stays in "开发中" until you submit the release review; unlimited users.
- Open the app detail page and copy Appkey (API Key) and Secretkey — these two are the only values this plugin needs (
AppidandSignkeyare not used). - Leave the OAuth redirect / callback URI empty: the plugin uses the device-code flow and never listens for a callback. Scope is
basic,netdisk; the basic netdisk interfaces are enabled by default, nothing to apply for.
Already have an app? Reuse it — an app can authorize any Baidu account, but the number of authorized users is capped by its purpose (see docs/APP-SETUP.md).
Step 1 — enter the credentials
Settings → 百度网盘备份 → 应用凭证
The same card carries a built-in six-step walkthrough (collapsed by default — click 查看图文教程): sign in, developer verification, create the app, pick the app purpose, copy the two values, leave the callback empty. Each step says what actually matters, and the three Open Platform links are printed in full so they can be copied when the desktop shell refuses to open them.
Paste the AppKey and SecretKey, then 保存凭证. The SecretKey is write-only: the page never shows it again, and re-entering it replaces the stored value. 清除凭证 removes both copies.
Storage order (first hit wins):
| Order | Where | Notes |
|---|---|---|
| 1 | env BAIDU_API_KEY + BAIDU_API_SECRET | for CI / one-off debugging; overrides the page |
| 2 | DSH credential store, record dsh-baidu-backup/app | written by the settings page |
| 3 | ~/.dsh-baidu-backup/app.json | written too, so the standalone CLI works while DSH is closed |
Step 2 — authorize your account
Settings → 百度网盘备份, or the tool:
baidu_backup_auth(action="start") → returns user_code and verification_url
(open the URL in any browser, enter the code, confirm)
baidu_backup_auth(action="poll", deviceCode="…")
The device code is valid for 5 minutes. Then refresh the account card, confirm the account name and capacity, and run a dry run.
Step 3 — back up
- Choose the 工作区备份目录 (workspace folder to back up). Click 浏览… on Windows, or type the full path; leave it empty to fall back to the default.
- 预演(不上传) to see the pending workload.
- 立即备份, then enable 开启定时自动备份 once you are happy with the destination.
What it does
- Device-code sign-in. One tool call returns an 8-character code; open Baidu's verification page on any device, type the code, done. No callback server, no 936 locale switch.
- Incremental upload. The remote tree is listed first; a file counts as synced when the remote path exists at the same byte size. Only new or changed files are transferred, so repeated runs are cheap.
- Resumable blocks. Uploads follow Baidu's xpan contract at a fixed 4 MB block size; block hashes are lowercase hex MD5 (base64 is rejected with
errno=2).precreateis called withautoinit=1, whose returnedblock_listis the list of block indices that still need uploading — read it as indices, not hashes. A failed file is retried up to 3 times on transient network errors. - Parallel files. Files are uploaded concurrently (
concurrency, default 4). Slices inside one file stay sequential. - Emoji-safe paths. Baidu rejects any non-BMP character (U+10000 and above) in a file name with
errno=-7and anillegal_charslist — 🔥🏆💥🚀 are illegal, while ✨✅★℃ are fine. Such characters are deterministically replaced with_so the remote path stays stable across runs and incremental comparison does not re-upload forever. - Two scopes.
fullbacks up everything;lightskips regenerable bulk (monthly-report intermediates, template backups, model weights). - Scheduled. An in-process timer backs up every N hours or daily at a fixed local time, with catch-up after downtime — see docs/SCHEDULE.md. A standalone CLI (
scripts/backup-cli.mjs) does the same from Windows Task Scheduler when DSH is closed. - Settings page. A
settings.sectionpanel under Settings → 百度网盘备份 edits every parameter, shows account capacity and the last run, and can start a backup or a dry run in the background while polling progress. Its JSON backend lives at/dsh-baidu-backup/*(lib/hostApi.js). - Remote audit. List how many files and bytes actually landed on the netdisk.
Installation
Add it from this repository — DSH's 添加插件 dialog accepts a Git address, a package name, an archive URL, or a local absolute path:
https://github.com/Smazinge/dsh-baidu-backup
A Git install lands in node_modules as a copy: you cannot hot-edit it and there is no "update" button, so uninstall and reinstall to upgrade. Restart DSH once after installing.
From a local checkout (recommended while iterating):
plugin_manager(action="install_bundle", target="<absolute path to this directory>")
# returns application:"restart-required" → restart DSH
The package is published under the MIT license and declares no build script, so installing it runs no build approval step.
Usage
baidu_backup_plan() → dry run, shows the pending workload
baidu_backup_run() → upload
baidu_backup_run(targets=["space"], profile="light")
baidu_backup_run(concurrency=8) → more parallel files when upstream is idle
baidu_backup_remote() → confirm what is on the netdisk
Automate it:
baidu_backup_schedule(action="set", everyHours=6) → every 6 hours
baidu_backup_schedule(action="set", dailyAt="03:30") → daily at 03:30 local
baidu_backup_schedule(action="status") → last success, next verdict
baidu_backup_schedule(action="run-now") → check and run immediately
baidu_backup_schedule(action="off") → disable
The scheduler is only a trigger; the real gate is shouldRun() in lib/schedule.js, keyed on the persisted last-success timestamp. So a downtime-spanning gap is caught up on the next start, and only a fully clean run advances the pointer. Full details and the Task Scheduler recipe: docs/SCHEDULE.md.
Or do it from the GUI: Settings → 百度网盘备份. Toggle "开启定时自动备份", pick every-N-hours or daily-at, choose the scope and profile, then "保存并生效" — the timer is re-armed immediately, no restart. The same page shows account capacity, the last successful run, the current verdict, and buttons for backup / dry run / stop.
Implementation notes worth keeping
- Listing must be a BFS over
file?method=list&recursion=0.recursion=1on that endpoint is ignored.multimedia?method=listall&recursion=1does recurse but silently under-reports (measured: 3706 files reported vs 4626 actually present in/DSH备份/space), which makes every subsequent run think everything is missing and re-upload it. The BFS costs more requests (a 46k-file tree takes ~18 min) but is exact. - Directory creation:
POST /xpan/file?method=createwithpath=…&isdir=1&rtype=0./xpan/createreturns an HTML 403 "page not found". - No per-directory
makeDir:precreate/createcreate missing parents on their own, so only the remote root is ensured. - List rate limit:
errno=31034 hit frequency limit— listing backs off and retries instead of failing the whole run. - Zero-byte files also require a hex MD5 block (
d41d8cd98f00b204e9800998ecf8427e); base64 fails the same way as for normal files. refresh_tokenis single-use. A second refresh with the same value fails withrefresh token has been used; store the rotated value immediately.
Settings page internals
The client half is lib/client.js, hand-written (no bundler is available in a plain profile) and loaded through the browser module protocol:
window.__ModuleLoader__.load({ id: 'dsh-baidu-backup', factory: (require) => { … return module.exports } })
package.json declares dsh.client: { platform: 'web', inject: [...] } plus an ./client export — without both, the Host half loads but no settings section appears. The panel registers into the settings.section slot and gets its data from:
| Route | Method | Purpose |
|---|---|---|
/dsh-baidu-backup/status | GET | config, describe, verdict, last-run state, app-credential state, job view, target table |
/dsh-baidu-backup/account | GET | account name and quota |
/dsh-baidu-backup/app-creds | GET / POST | read (SecretKey never returned) or save app credentials |
/dsh-baidu-backup/app-creds/clear | POST | delete stored app credentials |
/dsh-baidu-backup/config | POST | save a patch, re-arm the timer, return the normalized config |
/dsh-baidu-backup/workspace-picker | POST | open the native Windows folder dialog |
/dsh-baidu-backup/run | /plan | POST | start a background backup or dry run (one at a time) |
/dsh-baidu-backup/cancel | POST | abort the running job |
Writes are rejected with 403 when an Origin header is present and does not match Host, so another site cannot drive the backup. Workspace-path changes additionally require a loopback peer plus the private x-dsh-backup-settings: workspace header, so a random page cannot point the backup at an arbitrary folder. The client resolves the API prefix from document.baseURI, so it keeps working behind a reverse proxy sub-path.
Backup scope
| Target | Local path | Remote path |
|---|---|---|
dsh | $DSH_HOME (default C:\Users\<you>\.dsh) | /DSH备份/.dsh |
space | Folder saved in Settings → 百度网盘备份, then DSH_BACKUP_WORKSPACE, then an existing space folder beside the local plugin directory | /DSH备份/space |
Set the workspace path from the local DSH settings page. Enter an existing folder's full path and save. Clear the field to restore the default. Scheduled backups and CLI backups use the same saved path. The default scope skips the Quark Skill's quarkclouddrive and .quarkclouddrive directories so official-Skill authorization files stay local. Both remote root folders are configurable per install by editing lib/runner.js if you want a different layout.
Known limitations
- 4 GB per file. Baidu's xpan slices are a fixed 4 MB with at most 1024 slices. Larger files are skipped and reported; split or archive them first.
- Size-based change detection. Remote MD5s are not fetched (unrealistic at 20 GB), so an edit that keeps the same byte size is not detected. Delete the remote file or rename it to force a re-upload.
- No remote deletion. Files deleted locally stay on the netdisk; the run only reports how many extra remote files it saw.
- Runs synchronously. A first full backup can hold the turn for hours depending on upstream bandwidth. Run
profile="light"first to prove the path, then go full. (The settings page's "立即备份" instead runs in the background and polls progress, so closing the panel does not stop it.) - Renames re-upload. The comparison keys on path and size only.
- The in-process timer needs DSH running. While DSH is closed nothing is backed up; missed rounds are caught up at next start. Use
scripts/install-task.ps1if you need backups with DSH fully quit. - Windows-oriented extras. The folder picker and
scripts/install-task.ps1are Windows-only. On other platforms type the path by hand and skip the task script; the Node CLI works everywhere. - Rate limits and quotas are the account's. A free account with little space or a shared upstream IP will hit
errno=-11015/31034; the plugin retries with backoff but cannot create capacity.
Credential storage
- App credentials (AppKey/SecretKey): DSH credential record
dsh-baidu-backup/appplus~/.dsh-baidu-backup/app.json(0600 where the OS honours it). SecretKey is never returned by any route. Clear both with 清除凭证 orPOST /dsh-baidu-backup/app-creds/clear. - Account token: DSH credentials service as
records/dsh-baidu-backup/token(grant), falling back to~/.dsh-baidu-backup/token.json.baidu_backup_auth(action="logout")clears the token only — your app credentials stay.
License
MIT.
Related plugins
archify (deepseek-harness)
tt-a1i/archify
WeKnora (dsh-weknora)
tencent/weknora
next-ai-draw-io (dsh-plugin)
dayuanjiang/next-ai-draw-io
AiToEarn (dsh-plugin-aitoearn)
yikart/aitoearn