home-hosted 0.9.3 → 0.9.5

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.
Files changed (33) hide show
  1. package/AGENTS.md +27 -21
  2. package/README.md +109 -50
  3. package/dist/cli.js +1289 -172
  4. package/dist/cli.js.map +1 -1
  5. package/docs/DDNS.md +6 -8
  6. package/docs/NOTIFICATIONS.md +6 -0
  7. package/docs/RESTORE_DEMO.md +128 -0
  8. package/docs/REVERSE_PROXY.md +23 -12
  9. package/docs/SERVERS.md +50 -2
  10. package/docs/UI_CREATION.md +7 -7
  11. package/docs/demo/blank-host-restore.sh +192 -0
  12. package/package.json +3 -1
  13. package/uis/stock/dist/assets/de-DI7SS5ZM.js +1 -0
  14. package/uis/stock/dist/assets/es-DDPUYXdi.js +1 -0
  15. package/uis/stock/dist/assets/fr-Dpyr2qTp.js +1 -0
  16. package/uis/stock/dist/assets/index-BtE1z5wU.css +2 -0
  17. package/uis/stock/dist/assets/{index-DVmJrO-t.js → index-JBfH8bkX.js} +10 -8
  18. package/uis/stock/dist/assets/ja-CTGEGJ4n.js +1 -0
  19. package/uis/stock/dist/assets/ko-BSVsEsYY.js +1 -0
  20. package/uis/stock/dist/assets/ru-DvSoJlxX.js +1 -0
  21. package/uis/stock/dist/assets/vi-BTIQb_8V.js +1 -0
  22. package/uis/stock/dist/assets/zh-CN-D2-g9feN.js +1 -0
  23. package/uis/stock/dist/index.html +2 -2
  24. package/uis/stock/dist/ui.json +3 -3
  25. package/uis/stock/dist/assets/de-BVk31frd.js +0 -1
  26. package/uis/stock/dist/assets/es-BLevhZGM.js +0 -1
  27. package/uis/stock/dist/assets/fr-S3YXRHdG.js +0 -1
  28. package/uis/stock/dist/assets/index-GxTN2fYn.css +0 -2
  29. package/uis/stock/dist/assets/ja-BOB-E8_K.js +0 -1
  30. package/uis/stock/dist/assets/ko-Dc88YLt7.js +0 -1
  31. package/uis/stock/dist/assets/ru-BBxCT8MK.js +0 -1
  32. package/uis/stock/dist/assets/vi-CxubJ_Mw.js +0 -1
  33. package/uis/stock/dist/assets/zh-CN-BIvisZnl.js +0 -1
package/AGENTS.md CHANGED
@@ -8,14 +8,18 @@ State lives only in `$HHOSTED_HOME/.hh` (default `~/.home-hosted/.hh`). Global f
8
8
  level: `settings.json` (listener, auth, TLS policy, host vitals, backups, reverse proxy),
9
9
  `workspaces.json`, `.control-secrets.json` (0600: password hash, API token hash), `.tls/`, `.backups/`,
10
10
  `.ui/`, `.logs/` (the panel console), `.proxy/` (the engine, its generated config and nanny state), and
11
- `run.json` (the live daemon's pid/url/token, 0600). Every workspace owns `.hh/<id>/`: `settings.json`
12
- (server defaults, log retention, notifications, DDNS), `servers.config.json`, `.secrets.json` (0600:
13
- Telegram bot tokens, one per destination, plus DDNS credentials sealed with AES-256-GCM under
14
- `HHOSTED_DDNS_SECRET` — only DDNS is sealed, because it is the one thing replayed to a third party), `.logs/` (per server, `<id>.log`
15
- plus `<id>.log.1` when it rotates), and `.state/` (nanny state, its 0600 spawn spec until read,
16
- `ddns.json`). A home still on the 0.6.x layout is **refused** by `ensureLayout()`, which names the file
17
- and tells the person to install the latest 0.7.x; 0.8.0 does not relocate it. **The package ships no
18
- servers**: never commit a config, a seed entry, or a path that names one.
11
+ `run.json` (the live daemon's pid/url/token, 0600).
12
+
13
+ Every workspace owns `.hh/<id>/`: `settings.json` (server defaults, log retention, notifications,
14
+ DDNS), `servers.config.json`, `.secrets.json` (0600: Telegram bot tokens, one per destination, plus
15
+ DDNS credentials sealed with AES-256-GCM under `HHOSTED_DDNS_SECRET` — only DDNS is sealed, because it
16
+ is the one thing replayed to a third party), `.logs/` (per server, `<id>.log` plus `<id>.log.1` when it
17
+ rotates), and `.state/` (nanny state, its 0600 spawn spec until read, `<id>.run.json` — the last
18
+ detached child, which is how an orphan is found, and `ddns.json`).
19
+
20
+ A home still on the 0.6.x layout is **refused** by `ensureLayout()`, which names the file and tells the
21
+ person to install the latest 0.7.x; 0.8.0 does not relocate it. **The package ships no servers**: never
22
+ commit a config, a seed entry, or a path that names one.
19
23
 
20
24
  ## Docs
21
25
 
@@ -38,7 +42,7 @@ Where knowledge lives, and when to reach for each:
38
42
  | [`.agentDocs/GOTCHAS.md`](.agentDocs/GOTCHAS.md) | the traps this codebase already paid for, with causes |
39
43
  | [`.agentDocs/COMPATIBILITY.md`](.agentDocs/COMPATIBILITY.md) | config and UI compatibility, migrations |
40
44
  | [`.agentDocs/RELEASING.md`](.agentDocs/RELEASING.md) | how a release is cut, and which version to dispatch |
41
- | [`docs/SERVERS.md`](docs/SERVERS.md) | entries, port conflicts, persistent entries |
45
+ | [`docs/SERVERS.md`](docs/SERVERS.md) | entries, presets, port conflicts, persistent entries |
42
46
  | [`docs/NOTIFICATIONS.md`](docs/NOTIFICATIONS.md) | notification destinations: Telegram, webhooks, shared defaults |
43
47
  | [`docs/DDNS.md`](docs/DDNS.md) | dynamic-DNS providers and hostnames |
44
48
  | [`docs/REVERSE_PROXY.md`](docs/REVERSE_PROXY.md) | the Caddy engine, routes, certificates |
@@ -116,10 +120,12 @@ workspace config guard, so a busy default port turns config tests red for the wr
116
120
  These prevent defects if broken. The *why* for the non-obvious ones is in
117
121
  [`.agentDocs/GOTCHAS.md`](.agentDocs/GOTCHAS.md).
118
122
 
119
- - **Server-agnostic core; UIs are clients.** No blessed ids, no `dataDir`-style globals: a server gets
120
- only its own `command`/`args`/`env`/`dataEnvs`/`envFile`/`bootstrap`, and `#src/*` inside `src/` is
121
- the only import form — UIs use `@shared/*` (and `@server` for types only). A test fails if a core
122
- file learns one.
123
+ - **A server gets only its own fields; UIs are clients.** No blessed ids and no `dataDir`-style
124
+ globals: an entry is `command`/`args`/`env`/`dataEnvs`/`envFile`/`bootstrap`, and `#src/*` inside
125
+ `src/` is the only import form — UIs use `@shared/*` (and `@server` for types only). A test fails
126
+ if a core file names a particular server. Integrations the panel owns as infrastructure (the proxy
127
+ engine, docker's container lookup, notification providers, DDNS) are not server entries and are
128
+ expected in `src/`.
123
129
  - **UIs are external clients.** Nothing in `src/**` may know a UI's markup or files;
124
130
  `$HHOSTED_HOME/.hh/.ui` overrides the packaged UI at runtime.
125
131
  - **`src/shared` has exactly one declaration per member** — neither a UI nor `src/**` may re-declare
@@ -132,7 +138,7 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
132
138
  `README.md` are exempt — neither is in the built asset).
133
139
  `src/shared/**` is a UI build input, so a runtime contract needs the bump too — the hook does not
134
140
  inspect that commit. **`tag` and `unix` are build provenance**, stamped into `dist/ui.json` by
135
- `build-uis.mjs`; never committed to `public/ui.json`.
141
+ `build-uis.mjs`; never committed to `uis/<name>/public/ui.json`.
136
142
  - **Paths.** `dataRoot` is state, under `dataRoot/.hh`; `projectDir` is the base for relative entry
137
143
  paths. `{…}` and `${ENV}` expand in config — the full list is the table in
138
144
  [`docs/SERVERS.md`](docs/SERVERS.md), which is what to keep in step. No package-relative state.
@@ -153,8 +159,9 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
153
159
  per-workspace service through `PanelService.requireWorkspace(id)`, never a module global.
154
160
  - **A restore writes only where a config says** — archive allowlist, `origin` matching first, symlinks
155
161
  never recreated.
156
- - **A port is only ever freed by re-listing its listeners.** `free-port` never trusts a pid quoted in a
157
- message, and refuses any listener in `supervisedPids()` instead of killing it.
162
+ - **A port is only ever freed from a fresh lookup, never a quoted pid.** `free-port` re-lists the
163
+ listeners and refuses any in `supervisedPids()` instead of killing it; a docker-published port has
164
+ no pid this user may see, so the container docker reports publishing *that* port is stopped instead.
158
165
  - **A live pid is not the running panel.** Pids are recycled and a zombie still answers signal 0, so `up`/`status`/`down` decide
159
166
  with `runtimeIsAlive`/`runtimeLiveness` (pid **plus** `run.json`'s own `startedAt`), never
160
167
  `isProcessAlive` alone. Only `'gone'` deletes a record; `'unknown'` counts as alive, and `'recycled'`
@@ -206,8 +213,8 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
206
213
 
207
214
  **Prune verbose, keep correctness** — code, comments, docs alike.
208
215
 
209
- - Code: a comment only for non-obvious *intent*, never to restate the line, and never long. A block
210
- arguing for its own change is a commit message.
216
+ - Code: a comment only for non-obvious *intent*, never to restate the line, and never long. An
217
+ argument for the change belongs in the commit message.
211
218
  - Docs: one idea per sentence. Cut anything that would not change what a reader does.
212
219
  - Delete history `git log` already holds — keep the *rule* that came out of it, not the story.
213
220
  - **Never drop a caveat to save a line.** Concise means no filler, not fewer facts.
@@ -218,9 +225,8 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
218
225
 
219
226
  - **Concise first read**, depth behind collapsible `<details>` spoilers, and **visuals for skimmers** —
220
227
  the media in `docs/media/` is regenerated by `pnpm run media`.
221
- - **Docs ship with the change.** A
222
- user-visible change updates the docs that describe it in the *same commit*. A stale doc is a bug like
223
- stale code.
228
+ - **Docs ship with the change.** A user-visible change updates the docs that describe it in the *same
229
+ commit*. A stale doc is a bug like stale code.
224
230
 
225
231
  ## Where to extend
226
232
 
package/README.md CHANGED
@@ -59,7 +59,7 @@ command or a `docker compose` stack.
59
59
  │ gateway │ │ files │ │ bot │
60
60
  │ :4000 │ │ :4010 │ │ ... │
61
61
  └────┬────┘ └─────────┘ └─────────┘
62
- │ compose up -d
62
+ │ compose up
63
63
  ▼
64
64
  ┌────────────┬────────────┬────────────┐
65
65
  │ gateway │ postgres │ redis │ restarts ↻
@@ -75,8 +75,8 @@ command or a `docker compose` stack.
75
75
  | ❌ **"Move it to the new box"** | One archive: config **and** data, restored on a blank host |
76
76
  | ✅ **home-hosted** | Declare it once, watch it forever, one command to stop it all |
77
77
 
78
- It ships with **nothing**: no blessed paths, no opinion about what you run — a server is a command,
79
- some arguments, and the environment you give it:
78
+ It ships with **no servers configured**: what you run is a command, some arguments, and the
79
+ environment you give it. A preset can fill that in for you, and you can change every field after:
80
80
 
81
81
  ```json
82
82
  { "id": "gateway", "command": "node", "args": ["server.js"], "port": 4000, "autostart": true }
@@ -84,7 +84,8 @@ some arguments, and the environment you give it:
84
84
 
85
85
  <sub>Manage them from the panel, `home-hosted start|stop <id>` from a shell, `home-hosted status --json`,
86
86
  or `GET /api/state`; `GET /healthz` is the same status line for your own monitor, no session needed —
87
- `503` when an autostart server has crashed or a running one is failing its health check.</sub>
87
+ `503` when a server has crashed, when the panel stopped one because it could not serve, or while
88
+ a running one is failing its health check.</sub>
88
89
 
89
90
  ---
90
91
 
@@ -154,6 +155,8 @@ state/.hh/* # secrets, logs, TLS keys and archives s
154
155
  !state/.hh/settings.json # …but the workspace definitions are committed
155
156
  !state/.hh/workspaces.json
156
157
  state/.hh/*/*
158
+ !state/.hh/*/ # git will not descend into an excluded directory,
159
+ # so the directories must be un-ignored first
157
160
  !state/.hh/*/settings.json
158
161
  !state/.hh/*/servers.config.json
159
162
  data/ # per-server data directories, declared through dataEnvs
@@ -210,7 +213,7 @@ home-hosted set-token --generate
210
213
  curl -H "Authorization: Bearer hh_9uA2…" http://127.0.0.1:3999/api/state
211
214
  curl -H "Authorization: Bearer hh_9uA2…" -X POST 'http://127.0.0.1:3999/api/servers/omniroute/restart?workspace=default'
212
215
  curl -N -H "Authorization: Bearer hh_9uA2…" 'http://127.0.0.1:3999/api/servers/omniroute/stream?workspace=default' # SSE
213
- home-hosted status --json # machine-readable: pid, url, health, paths
216
+ home-hosted status --json # machine-readable: running, liveness, degraded, pid, url, paths
214
217
  ```
215
218
 
216
219
  A token has the same authority as a signed-in browser and outlives restarts; `set-token --clear`
@@ -225,13 +228,13 @@ default workspace.
225
228
  | `GET /api/state` | the full snapshot: global settings, every workspace with its servers, host vitals | ❌ |
226
229
  | `GET`/`POST /api/workspaces`, `PATCH`/`DELETE /api/workspaces/:id` | the registry: list, create, rename, remove | ❌ |
227
230
  | `GET /api/events` | SSE: the live state, plus logs (`?logs=0`, `?serverId=…`; a `server` payload carries its `workspaceId`) | ❌ |
228
- | `GET`/`POST /api/servers`, `POST /api/servers/{start,stop}-all` | that workspace's entries, and its lifecycle for all of them | ✅ |
229
- | `GET`/`PATCH`/`DELETE /api/servers/:id` | one entry | ✅ |
231
+ | `GET`/`POST /api/servers`, `POST /api/servers/start-all`, `POST /api/servers/stop-all` | that workspace's entries, and its lifecycle for all of them | ✅ |
232
+ | `GET`/`PATCH`/`DELETE /api/servers/:id`, `PUT /api/servers/:id` | one entry — `PUT` creates or replaces it, so a re-run converges | ✅ |
230
233
  | `POST /api/servers/:id/{start,stop,restart}`, `POST /api/servers/:id/free-port` | one entry's lifecycle, and freeing its port | ✅ |
231
234
  | `GET /api/servers/:id/logs`, `GET /api/servers/:id/stream` | that entry's buffered lines, and its SSE | ✅ |
232
235
  | `GET /api/logs` | persisted history and files | ✅ |
233
236
  | `GET`/`PUT /api/ddns`, `/api/ddns/credentials/:id`, `/api/ddns/check` | that workspace's Dynamic DNS policy, credentials and a check | ✅ |
234
- | `PUT`/`DELETE /api/notifications/token`, `POST /api/notifications/{test,detect-chats}` | that workspace's bot credential and a test send | ✅ |
237
+ | `PUT`/`DELETE /api/notifications/destinations/:id/token`, `POST /api/notifications/destinations/:id/{test,detect-chats}`, `POST /api/notifications/test-webhook` | one destination's bot credential, and a test send | ✅ |
235
238
  | `GET`/`PATCH /api/settings/workspace` | server defaults, logs, notifications | ✅ |
236
239
  | `GET`/`PATCH /api/settings` | panel-wide: listener, authentication, TLS, host vitals, backups | ❌ |
237
240
  | `GET`/`POST /api/backups`, restore | archives | ❌ |
@@ -242,7 +245,10 @@ default workspace.
242
245
  ✅ takes `?workspace=<id>`; ❌ is panel-wide. Omitting `?workspace` means `default` workspace is used.
243
246
 
244
247
  `GET /openapi/spec.json` describes all of it, `/openapi/ui` is the browsable version, and every error
245
- comes back as one envelope (`{ message, code, detail }`) with a stable `code` a tool can branch on.
248
+ comes back as one envelope (`{ message, code, detail }`) with a stable `code` a tool can branch on. The
249
+ document declares its own `securitySchemes` (`bearerAuth`), every documented 2xx carries a schema, and
250
+ each operation is tagged — so `openapi-typescript`, `openapi-generator` or a docs renderer can generate
251
+ a working client without hand-written glue.
246
252
 
247
253
  </details>
248
254
 
@@ -268,10 +274,10 @@ can be told what to be: *"Help me build a UI for home-hosted: nostalgic game the
268
274
  | | |
269
275
  | --- | --- |
270
276
  | 🗂 **Workspaces** | One panel, many scopes: pick a workspace in the header and it owns its servers, secrets, logs and settings. Create, rename and delete them there. Panel-wide things — listener, auth, host vitals, backups, TLS, UI — stay in **Global settings**. |
271
- | 🚦 **Lifecycle** | Start, stop, restart from the panel or the API; `autostart` entries come up with it. |
277
+ | 🚦 **Lifecycle** | Start, stop, restart from the panel or the API; `autostart` entries come up with it. A process left behind by a renamed or removed entry is listed on **Servers** with a stop button, instead of running invisible. |
272
278
  | 📝 **Hand edits welcome** | Change a workspace's `servers.config.json` in an editor, a `git checkout` or a config tool: the panel notices within seconds, no restart. A file it cannot read is reported in the panel, and the running servers are left alone. |
273
279
  | ♻️ **Auto-restart** | Exponential backoff on crash, with the counter reset once a process stays up. The budget is remembered across a restart of the panel. |
274
- | 🩺 **Health that acts** | TCP or HTTP probes per server: warn on the card, force a restart after a timeout, check ports before starting — and [follow or replace](./docs/SERVERS.md#when-a-program-restarts-itself) a program that restarts itself. |
280
+ | 🩺 **Health that acts** | TCP or HTTP probes per server: warn on the card, force a restart after a timeout (bounded by the same retry budget as a crash, so a permanently sick entry stops instead of restarting forever), check ports before starting — and [follow or replace](./docs/SERVERS.md#when-a-program-restarts-itself) a program that restarts itself. |
275
281
  | 🔗 **Ordered startup** | `dependsOn` waits for a dependency to be *healthy* — not merely spawned. `stop-all`/`down` stop dependents before their dependencies; stopping one server names the dependents it leaves running. [SERVERS.md](./docs/SERVERS.md#field-reference) |
276
282
  | 📜 **Logs** | Live per-server stream, buffer plus rotated files on disk, search, filter to one stream, download, one click to clear. |
277
283
  | 📈 **Resources** | CPU and RSS of the whole process tree, with an optional memory ceiling that triggers a restart. |
@@ -284,7 +290,7 @@ can be told what to be: *"Help me build a UI for home-hosted: nostalgic game the
284
290
  | 🌍 **Nine languages** | English, Vietnamese, Chinese, Japanese, Spanish, Korean, Russian, French, German — picked on the login page or in **Global settings → Language**, kept per browser. |
285
291
  | 🎨 **BYOU — Bring Your Own UI** | Upload a static build, `ui-update` to follow its releases, `ui-revert` to go back. [UI_CREATION.md](./docs/UI_CREATION.md) |
286
292
  | 🔐 **Security** | Cookie sessions, API tokens, scrypt hashes, per-IP lockout, optional TLS, and a refusal to expose itself without a password. |
287
- | 🧩 **No special treatment** | A server is `command` + `args` + `env` + `cwd`; nothing is built in for any particular app. |
293
+ | 🧩 **Bring any program** | A server is `command` + `args` + `env` + `cwd` — if it runs in a shell, it runs here. Presets fill the form in for common ones; nothing requires one. |
288
294
  | 🖥 **Cross-platform** | Linux, macOS and Windows: `/proc`, `ps` or Win32_Process, process groups or `taskkill /T`, no shell dependencies. |
289
295
 
290
296
  ---
@@ -350,7 +356,8 @@ restarts itself), and how hand-edits are validated: [SERVERS.md](./docs/SERVERS.
350
356
  | `home-hosted stop <id>` | stop one server, nothing else (`--workspace <id>`) |
351
357
  | `home-hosted restart <id>` | restart one server, nothing else (`--workspace <id>`) — the same as the panel's per-server Restart |
352
358
  | `home-hosted logs` | read the panel's own console output — the file `up` redirects it into (`--lines`, `--follow`, `--json`) |
353
- | `home-hosted set-password` | set the panel password without opening a browser |
359
+ | `home-hosted backup` | list, create or restore an archive without a browser (`create`, `restore <name> --confirm`, `--password`, `--include`) — see [RESTORE_DEMO.md](./docs/RESTORE_DEMO.md) |
360
+ | `home-hosted set-password` | set the panel password without opening a browser; a running panel picks it up at once and signs every existing session out |
354
361
  | `home-hosted set-token` | set the API token scripts and agents use (`--generate`, `--clear`) |
355
362
  | `home-hosted migrate` | bring every config up to the schema this release understands (`--dry-run`, `--yes`) |
356
363
  | `home-hosted init` | scaffold a self-contained project, whose scripts keep state in the repo (`--home ./state`) |
@@ -454,12 +461,13 @@ Everything binds `127.0.0.1` until you say otherwise.
454
461
  are sealed with AES-256-GCM under `HHOSTED_DDNS_SECRET` (default `hh` — set your own).
455
462
  - **Behind a proxy** pick how far to trust it, and let `cookieSecure: auto` add `Secure` on https — or
456
463
  upload a PEM pair and let home-hosted terminate TLS itself.
457
- - **`loopback`** trusts `x-forwarded-*` only when the request really came from this machine. That is the
458
- right choice for a proxy on the same host: the panel gets the real client address for its lockout and
459
- the logs, and a forged header from anywhere else is ignored.
460
- - **on** trusts the header from *any* peer. Only when the proxy is the only way in: the client address
461
- then comes from the caller's own header, so the per-IP lockout counts per *forged* address and stops
462
- throttling brute force. The panel warns at startup when that combination is exposed.
464
+ - **`loopback`** trusts `x-forwarded-*` only when the request came from this machine. Right for a
465
+ proxy on the same host: the panel gets the real client address for its lockout and the logs, and
466
+ a forged header from anywhere else is ignored.
467
+ - **on** trusts the header from *any* peer. Only when the proxy is the only way in: the client
468
+ address then comes from the caller's own header, so the per-IP lockout counts per *forged*
469
+ address and stops throttling brute force. The panel warns at startup when that combination is
470
+ exposed.
463
471
  - **off** ignores the header entirely. Use it when nothing sits in front, or when the proxy does not set
464
472
  one.
465
473
 
@@ -492,19 +500,19 @@ Provider tokens stay in the workspace's secrets file. **Providers and the config
492
500
  ## 💾 Backups
493
501
 
494
502
  **Global settings → Backups** archives the panel's own settings, its secrets and the TLS pair — plus
495
- every workspace you pick. It is two-level: the top of *Create backup…* lists the global items and
496
- each workspace; opening one lists its **settings**, **servers**, its **secrets** and every data
497
- directory its entries declare, and you can drop any single piece. Each secret has its own checkbox.
498
- *Restore…* shows the same list from an archive before anything is written. Either way it is an
499
- ordinary `.zip`, or WinZip AES-256 with a password, restored per path. Known build output and
500
- dependency directories (`node_modules`, `dist`, `.next`, framework caches) are skipped per entry;
501
- `backupIgnoreGenerated: false` captures them anyway.
502
-
503
- **Automatic backups** write one archive on a schedule you set — the page asks in hours; the config
504
- stores `intervalMs` — with a retention of its own (`Keep automatic`). The two counts are independent: `Keep` bounds the archives you take by hand,
505
- and a scheduled pass never prunes one of yours to make room for its own. Both live in the same
506
- directory, and an automatic archive is named `auto-…` so you can tell them apart — a name you drop
507
- in by hand with that prefix is treated as one, so do not use it.
503
+ every workspace you pick. It is two-level: *Create backup…* lists the global items and each workspace;
504
+ opening one lists its **settings**, **servers**, **secrets** and every data directory its entries
505
+ declare, and you can drop any single piece. Each secret has its own checkbox. *Restore…* shows the
506
+ same list from an archive before anything is written. Either way it is an ordinary `.zip`, or WinZip
507
+ AES-256 with a password, restored per path. Build output and dependency directories (`node_modules`,
508
+ `dist`, `.next`, framework caches) are skipped per entry; `backupIgnoreGenerated: false` captures them
509
+ anyway.
510
+
511
+ **Automatic backups** write one archive on a schedule you set — the page asks in hours, the config
512
+ stores `intervalMs` — with a retention of its own (`Keep automatic`). The two counts are independent:
513
+ `Keep` bounds the archives you take by hand, and a scheduled pass never prunes one of yours to make
514
+ room for its own. Both land in the same directory, and an automatic archive is named `auto-…` so you
515
+ can tell them apart — a name you drop in by hand with that prefix is treated as one, so do not use it.
508
516
 
509
517
  <details>
510
518
  <summary><b>🔑 Restoring a secret</b></summary>
@@ -520,7 +528,7 @@ Two things to know before restoring onto a machine already in use:
520
528
 
521
529
  - **The password hash and API token hash are secrets like any other.** Restoring them reinstates the
522
530
  old machine's password and long-lived token, so anyone holding that token keeps access. Leave them
523
- unticked, or rotate afterwards with `pnpm run set-token --generate`.
531
+ unticked, or rotate afterwards with `home-hosted set-token --generate`.
524
532
  - **`HHOSTED_DDNS_SECRET` is not in the archive.** DDNS credentials travel sealed under it, so a host
525
533
  with a different value cannot open them. Supply the same secret, or re-enter the credentials.
526
534
 
@@ -530,14 +538,62 @@ Two things to know before restoring onto a machine already in use:
530
538
  <summary><b>🚚 One archive is a whole setup</b></summary>
531
539
 
532
540
  Start a **blank** home-hosted anywhere — another machine, another user, a fresh container — upload the
533
- archive and restore. Definitions come back, data lands where *this* machine's config says, and
534
- `autostart` entries come up immediately.
541
+ archive and restore. Definitions come back, workspaces the target has never heard of are created with
542
+ their labels, data lands where *this* machine's config says, and `autostart` entries come up
543
+ immediately.
535
544
 
536
- It works because an archive carries each workspace's `settings.json` and `servers.config.json`, and
537
- paths are matched by the **declaration** (`omniroute:DATA_DIR`), not by an absolute path from the
538
- source machine. A restore never writes where no config declares. A declaration using `{projectDir}`,
539
- `{dataRoot}` or `{home}` follows the restoring panel (`{projectDir}` is `HHOSTED_PROJECT` or the
540
- panel's cwd, not `HHOSTED_HOME`); a literal absolute path is restored to that same path.
545
+ It works because an archive carries the workspace registry, each workspace's `settings.json` and
546
+ `servers.config.json`, and paths are matched by the **declaration** (`omniroute:DATA_DIR`), not by an
547
+ absolute path from the source machine. A declaration using `{projectDir}`, `{dataRoot}` or `{home}`
548
+ follows the restoring panel (`{projectDir}` is `HHOSTED_PROJECT` or the panel's cwd, not
549
+ `HHOSTED_HOME`); a literal absolute path is restored to that same path.
550
+
551
+ **A restore never writes where no config declares, and never across workspaces.** A data path is only
552
+ placed under a workspace the archive says it belongs to — if that workspace's `servers.config.json` is
553
+ not part of the restore, its data is reported as skipped rather than guessed at.
554
+
555
+ </details>
556
+
557
+ <details>
558
+ <summary><b>✅ What comes back, and what you still have to do</b></summary>
559
+
560
+ | | Restored | Still yours to do |
561
+ | --- | --- | --- |
562
+ | Panel settings, listener, host vitals, backups policy | ✅ | Restart the panel if the listener or TLS policy changed (the plan says so) |
563
+ | Workspaces, their order and labels | ✅ | — |
564
+ | `servers.config.json`, server defaults, log retention | ✅ | `autostart` entries start by themselves; the rest are one *Start* away |
565
+ | Data directories each entry declares | ✅ | Nothing — but see the consistency note below |
566
+ | Telegram bots and chats, webhook targets | ✅ | Send a test from *Notifications* if the chat id came from another account |
567
+ | DDNS hostnames and their accounts | ✅ | Credentials only open under the same `HHOSTED_DDNS_SECRET`; otherwise re-enter them |
568
+ | Panel password and API token | ⬜ ticked per secret | Leave unticked, or rotate with `home-hosted set-token --generate` |
569
+ | Reverse-proxy routes | ✅ | Automatic HTTPS certificates are reissued by the engine on the new host. A pair **you uploaded** for a `tls: "manual"` route is not in the archive — re-upload it |
570
+ | Reverse-proxy engine binary | ❌ | Installed again from *Global settings → Reverse proxy* |
571
+ | Server logs, crash history, nanny state | ❌ | These describe the old box; the new one starts a fresh history |
572
+ | A server's `envFile` | ❌ not archived | It is the machine-local layer by design — copy it yourself, or declare its directory in `backupPaths` |
573
+ | Environment variables the panel runs with | ❌ | `HHOSTED_*`, `HHOSTED_DDNS_SECRET`, and anything a `${ENV}` placeholder needs |
574
+
575
+ </details>
576
+
577
+ <details>
578
+ <summary><b>⚠️ A backup of a running database may not be restorable</b></summary>
579
+
580
+ Data directories are copied file by file while your servers keep running — the panel does not stop or
581
+ freeze anything to take an archive, because doing so would mean a backup could take your services down.
582
+
583
+ That is fine for files, uploads and most app data. It is **not** a consistent snapshot of a live
584
+ database: SQLite mid-transaction, a Postgres data directory, or a WAL in the middle of a write can all
585
+ be captured torn, and the copy will look complete while failing to open.
586
+
587
+ For anything with a real database, do one of these before relying on the archive:
588
+
589
+ - **Quiesce it** — stop that entry from the panel, take the backup, start it again; or
590
+ - **dump it properly** (`sqlite3 app.db ".backup out.db"`, `pg_dump`, `mysqldump`) into a directory you
591
+ declare in `backupPaths`, so the archive carries the dump rather than the live files.
592
+
593
+ **Restoring** has the mirror-image hazard, and the plan names it: a data path copied over while its
594
+ server is running is replaced under a live process, which keeps its old view and loses whatever it
595
+ wrote since. The restore reports those entries — `Data was replaced under a running server` — and
596
+ the fix is to stop and start each one, or stop them before applying.
541
597
 
542
598
  </details>
543
599
 
@@ -553,7 +609,11 @@ Two ship in this repo: `uis/stock`, and `uis/noc-console` for TUI and shortcuts
553
609
  attaches both as `home-hosted-ui-<name>.zip`. Yours can be anything that compiles to static files —
554
610
  the server never cares what built it.
555
611
 
556
- <sub>Install a UI from the CLI: `home-hosted ui-switch` `--asset noc-console` selects an UI directly, no flags interactively show official assets. Official UIs's version auto-sync when you update `home-hosted`. For unofficial UIs, `home-hosted ui-update` offers its newer releases to pick from — or `--old` for older (author must set up `ui.json` and GH releases).</sub>
612
+ <sub>Install a UI from the CLI: `home-hosted ui-switch --asset noc-console` selects a UI directly, and
613
+ with no flags it lists the official assets to pick from. An official UI is switched to the version
614
+ that matches your panel when you update `home-hosted`. For unofficial UIs, `home-hosted ui-update`
615
+ offers their newer releases — or `--old` for older ones (the author sets up `ui.json` and GitHub
616
+ releases).</sub>
557
617
 
558
618
  <details>
559
619
  <summary><b>🤖 Or have an agent build the UI you actually want</b></summary>
@@ -574,8 +634,8 @@ specific:
574
634
  <details>
575
635
  <summary><b>The panel is up but something is wrong — where do I look?</b></summary>
576
636
 
577
- `home-hosted logs` prints the panel's own console output, which is where it reports what it is
578
- doing and anything it could not finish:
637
+ `home-hosted logs` prints the panel's own console output — what it is doing, and anything it could
638
+ not finish:
579
639
 
580
640
  ```bash
581
641
  home-hosted logs # the last 50 lines
@@ -584,9 +644,8 @@ home-hosted logs --lines all # the whole thing, including the rotation
584
644
  home-hosted logs --json # { path, lines } — or one object per line with --follow
585
645
  ```
586
646
 
587
- It is the same file `status` names, and reading it needs no session or API token — a panel that
588
- is answering badly is exactly when you cannot get one. `up` prints the tail automatically when
589
- the panel fails to start.
647
+ It reads the same file `status` names, and needs no session or API token — a panel answering badly is
648
+ exactly when you cannot get one. `up` prints the tail when the panel fails to start.
590
649
 
591
650
  </details>
592
651
 
@@ -641,7 +700,7 @@ run.json the running panel (pid, url, token, mode 0600)
641
700
  <workspace>/servers.config.json your servers, plus meta: which release and schema wrote it
642
701
  <workspace>/.secrets.json Telegram token + DDNS credentials (mode 0600)
643
702
  <workspace>/.logs/ per-server logs: <id>.log, rotated to <id>.log.1 … (newest first)
644
- <workspace>/.state/ persistent entries' nanny state
703
+ <workspace>/.state/ nanny state, the last detached child (<id>.run.json) and ddns.json
645
704
  ```
646
705
 
647
706
  `home-hosted status` prints the paths.
@@ -656,9 +715,9 @@ proxy is the one panel-wide listener, and only when you switch it on: `80`/`443`
656
715
  or `4480`/`4443` unprivileged with your router forwarding to them
657
716
  ([REVERSE_PROXY.md](./docs/REVERSE_PROXY.md#ports)).
658
717
 
659
- **If that port is taken, `up` names who holds it** — the pid and the command line, when the OS will
660
- tell it — rather than only reporting the number. A `follow` entry adopts the process that replaced it;
661
- an unrelated listener is never signalled
718
+ **If that port is taken, `up` names the pid holding it** when the OS will say — rather than only
719
+ reporting the number — and exits, so a second panel never starts beside the first. A `follow` entry
720
+ adopts the process that replaced it; an unrelated listener is never signalled
662
721
  ([SERVERS.md](./docs/SERVERS.md#a-busy-port)).
663
722
 
664
723
  </details>