Skip to content

feat(backup): essentials backup (bots, memory, settings, conversations) with an in-place restore - #33

Merged
zereight merged 1 commit into
mainfrom
feat/essentials-backup
Nov 15, 2026
Merged

zereight merged 1 commit into
mainfrom
feat/essentials-backup

Conversation

@zereight

Copy link
Copy Markdown
Owner

What changed

Export can now make an essentials backup, and restoring one works on this computer or a new one.

  • Settings → Export backup has a choice of Essentials (recommended, default) or Everything. The validated preview shows which kind a file is.
  • What essentials carries: bots.json, bots/<id>/ (SOUL and the rest), each work folder's MEMORY.md, memory/ and skills/, settings files, messages.db (conversations), attachments/ and the other top-level state files.
  • What it leaves out:
    • checkpoints/, task-workspaces/, events/, native/, tool-results/, browser-uploads/.
    • Everything else in workspaces/<id>/: project clones, scripts and .claude/settings.json (see Why).
  • Restore:
    • The left-out roots are never moved, and bots/ and workspaces/ are never moved as a whole.
    • Only the children the backup carries (bots/<id>/<child>, workspaces/<id>/{MEMORY.md,memory,skills}) are swapped one by one. The replaced originals go to the safety copy.
    • The recovery journal records these as nested / nestedExisting, so an interrupted restore rolls back the same way the top-level swap does.
  • Strict validation:
    • summary.scope is allowlisted and must be essentials or full.
    • An essentials manifest that holds anything a restore keeps in place is refused, including case variants and files at the bot-folder level. Without this, a crafted archive could overwrite what is meant to stay.
    • The API takes scope (default full), so existing callers behave as before.
  • Code: the logic lives in a new server/workspace-backup-essentials.ts, next to workspace-backup-policy.ts / -team-private.ts. This keeps server/workspace-backup.ts under the 1,000-line ratchet (992).

Why

Exporting a real install fails with "The workspace exceeds the 10 GB backup limit." What people need to move their bots is a tiny share of the data folder.

Data folder (real install) Size
Whole folder ~15.6 GB, ~131k files
checkpoints/ 9.0 GB
workspaces/ 3.1 GB (14.3 GB with node_modules)
task-workspaces/ 1.6–4.2 GB
events / native / tool-results 1.4 GB
What essentials keeps ~0.26 GB

Why .claude/settings.json is left out: its hooks name absolute script paths. When the script is missing on the new computer, the hook exits non-zero and blocks the bot's tools.

How it was verified

Checks:

  • pnpm typecheck ✅
  • pnpm lint ✅
  • pnpm i18n:check ✅

Vitest, 120 related files (backup, settings, locales, shared): 1608 passed, 1 skipped.

New tests:

  • server/workspace-backup.test.ts → essentials workspace backups (12 tests):
    • Export contents and exclusions; a full backup has no scope.
    • Restore on the same computer: carried files are replaced or created. Clones, data.duckdb, checkpoints, task work, other bots' folders and .claude stay. The originals are in the safety copy.
    • Restore into an empty folder (new computer).
    • Rollback of an interrupted per-bot swap, both with the incoming files moved and not moved.
    • Unsafe journal paths are refused (6 cases).
    • Crafted archives are refused: checkpoints/…, Task-Workspaces/…, workspaces/a/repo/…, workspaces/a/.claude/…, Workspaces/…, a file at bots/README, a file at workspaces/a. Unknown scopes in options and in the manifest are refused too.
  • server/workspace-backup-http.test.ts: scope defaults to full, essentials is passed through, and an unknown scope gets 400.
  • src/components/WorkspaceBackupSettings.test.ts: essentials is checked by default; picking Everything sends full; the choice resets on reopen; the preview shows the scope.

scripts/testing guards: the file-size ratchet passes. analytics-docs.test.ts fails, and it fails the same way on unmodified main, so this PR does not cause it.

Before / After

Before (main):

  • Export on the real install: The workspace exceeds the 10 GB backup limit. (about 15.6 GB, about 131k files).

After: I ran the real export and restore code on an APFS copy-on-write clone of a real data folder. The live folder was not touched. The six big roots were swapped for marker files, and each work folder got a marker repo/ file.

Result
Essentials export 990 files, 235 folders, 264 MB (archive 265 MB), 7.4 s; 35 bots, 623 threads, 34,065 messages
Restore on the same computer restored; the MEMORY.md changed after the backup came back to the backup version; the marker repo/ file stayed; checkpoints, task-workspaces, events, native, tool-results and browser-uploads markers all stayed; data.duckdb stayed in the 3 bots that have one
Restore into an empty folder restored; bots 35 / messages 34,065 / threads 623, matching the summary; 35 SOUL.md and 35 MEMORY.md

How the design review changed it

I debated the plan with a reviewer bot before implementing. What changed:

  • No whole-folder moves for workspaces/ and bots/. The first design moved those folders whole and carried the work files back, and a rollback could lose repo clones. They now stay put and only their carried children are swapped, with journal entries for each.
  • .claude/settings.json left out because of the hook problem above.
  • Data tab tables (bots/<id>/data.duckdb) stay in place because of the per-child swap.
  • Notes and preview label: essentials has its own exclusion notes, and the preview shows the scope.
  • Older app versions refuse an essentials file instead of half-restoring it: their summary allowlist does not know scope.

Limits / not in this PR

  • No screenshots. The UI follows the existing radio-card pattern (PhoneDevicesSection) and is covered by component tests. Midnight/Daylight screenshots were not captured.
  • Translations: the 14 non-English/Korean strings were written by me and need review by a speaker.
  • Existing issues, separate from this PR:
    • bursts.db is not snapshotted.
    • A leftover bots.json.*.tmp is not excluded.
    • Full backups carry .claude/settings.json with the same absolute-path hooks.

Checklist

  • pnpm typecheck passes; the related vitest suites pass. I did not run the full pnpm test locally; the related 120 files did run.
  • Server behavior changes come with tests
  • No dist-server/ edits
  • No platform-specific code
  • No secrets in logs, responses, events, or argv

…s and conversations, and restores without touching work folders

A whole data folder easily passes the 10 GB / 100,000-file limit with turn checkpoints, conversation
work folders and project clones. Essentials leaves those out; its restore keeps them in place and swaps
bot folders' children (SOUL, MEMORY.md, memory/, skills) one by one with a journal it can roll back.
Export defaults to essentials in Settings; full stays available.
@zereight
zereight merged commit e366535 into main Nov 15, 2026
10 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant