home-hosted 0.9.5 → 0.9.6
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/AGENTS.md +7 -6
- package/README.md +6 -1
- package/dist/cli.js +601 -50
- package/dist/cli.js.map +1 -1
- package/docs/RESTORE_DEMO.md +86 -2
- package/docs/demo/blank-host-restore.sh +6 -4
- package/package.json +7 -9
- package/uis/stock/dist/ui.json +2 -2
package/docs/RESTORE_DEMO.md
CHANGED
|
@@ -30,15 +30,99 @@ that is what the archive carries.
|
|
|
30
30
|
|
|
31
31
|
## Backing it up
|
|
32
32
|
|
|
33
|
+
`create` plans first. That listing is what the archive *would* contain, and nothing has been written
|
|
34
|
+
yet:
|
|
35
|
+
|
|
33
36
|
```console
|
|
34
|
-
$ home-hosted backup create
|
|
35
|
-
|
|
37
|
+
$ home-hosted backup create --all
|
|
38
|
+
Plan — what a backup would capture; nothing has been written yet
|
|
39
|
+
settings global:settings
|
|
40
|
+
secrets global:secrets
|
|
41
|
+
- global:secrets:password
|
|
42
|
+
- global:secrets:apiToken
|
|
43
|
+
tls global:tls (does not exist yet)
|
|
44
|
+
workspace workspace:default
|
|
45
|
+
- workspace:default:settings
|
|
46
|
+
- workspace:default:servers
|
|
47
|
+
- workspace:default:data:/srv/blog/dump
|
|
48
|
+
|
|
49
|
+
Take this backup? [y/N] y
|
|
36
50
|
|
|
37
51
|
$ home-hosted backup list
|
|
38
52
|
1 archive in /home/you/.home-hosted/.hh/.backups
|
|
39
53
|
backup-2026-10-21-04-15-49-881.zip 4 KB 2026-10-21 04:15
|
|
40
54
|
```
|
|
41
55
|
|
|
56
|
+
`--all` is required: a scope is never assumed, so `backup create` with neither flag refuses and
|
|
57
|
+
lists what could be picked. `--confirm` skips the prompt, which is what a cron job wants. `--json` prints the same plan as JSON
|
|
58
|
+
and never applies, so a script or an agent can read it and decide.
|
|
59
|
+
|
|
60
|
+
### Working while the panel is stopped
|
|
61
|
+
|
|
62
|
+
`backup` does not need the panel. It drives the same service either way, so a stopped panel is fine —
|
|
63
|
+
which is the point, since stopping the services is what someone does before a careful backup or a
|
|
64
|
+
migration:
|
|
65
|
+
|
|
66
|
+
```console
|
|
67
|
+
$ home-hosted down
|
|
68
|
+
$ home-hosted backup create --all --confirm
|
|
69
|
+
backup created backup-2026-10-21-06-55-40-147.zip (3 KB)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
A **persistent** entry keeps running when the panel stops, so "panel off" is not "services off". Those
|
|
73
|
+
are named before the backup is taken, and it proceeds anyway — refusing would block the migration this
|
|
74
|
+
exists for:
|
|
75
|
+
|
|
76
|
+
```console
|
|
77
|
+
$ home-hosted backup create --all
|
|
78
|
+
Plan — what a backup would capture; nothing has been written yet
|
|
79
|
+
...
|
|
80
|
+
! 1 entry is still running (gitea) — its data may be captured mid-write
|
|
81
|
+
|
|
82
|
+
Take this backup? [y/N]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
One limit: a project started with `up --config <file>` reads that file only while the panel runs. The
|
|
86
|
+
flag is not written to any record, so an offline `backup` reads the default workspace's
|
|
87
|
+
`servers.config.json` and would miss it — start the panel first for that shape.
|
|
88
|
+
|
|
89
|
+
A restore writes a **lock** (`<state>/.hh/restore.lock`), taken by the service itself — so the panel's
|
|
90
|
+
own restore and this one exclude each other, and neither two shells nor a shell and the page can write
|
|
91
|
+
the same host at once. A lock left by a process that died is taken over; one held by a live process
|
|
92
|
+
names it and stops. A dry run takes none, because it writes nothing.
|
|
93
|
+
|
|
94
|
+
### Narrowing what an archive carries
|
|
95
|
+
|
|
96
|
+
`--include` takes the ids from the plan, comma-separated:
|
|
97
|
+
|
|
98
|
+
```console
|
|
99
|
+
$ home-hosted backup create --include workspace:default:servers,global:settings
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`--all` is the only way to say "everything" — giving **neither** flag is refused, not assumed, so the
|
|
103
|
+
destructive default cannot be reached by silence:
|
|
104
|
+
|
|
105
|
+
```console
|
|
106
|
+
$ home-hosted backup create --confirm
|
|
107
|
+
error name what to act on — pass --include <ids> or --all
|
|
108
|
+
|
|
109
|
+
available:
|
|
110
|
+
global:settings
|
|
111
|
+
global:secrets
|
|
112
|
+
workspace:default
|
|
113
|
+
workspace:default:data:/srv/blog/dump
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
An empty `--include` is refused too, rather than treated as "nothing selected" — a script passing an
|
|
117
|
+
unset `$LIST` gets an error instead of quietly backing up (or restoring) the whole machine:
|
|
118
|
+
|
|
119
|
+
```console
|
|
120
|
+
$ home-hosted backup create --include "$UNSET"
|
|
121
|
+
error --include is empty — name the ids to act on, or pass --all for everything
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`--include` and `--all` together is also refused, since one of them would silently win.
|
|
125
|
+
|
|
42
126
|
The archive is a plain zip. Its contents, in full:
|
|
43
127
|
|
|
44
128
|
```text
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
# Two hosts, one after the other, in throwaway directories:
|
|
6
6
|
#
|
|
7
7
|
# 1. host A — a panel with one entry (a MongoDB container) and some data in it
|
|
8
|
-
# 2. take a backup: `home-hosted backup create`
|
|
8
|
+
# 2. take a backup: `home-hosted backup create --all` (plans first, then `--confirm` applies)
|
|
9
9
|
# 3. host B — a *blank* home, nothing configured
|
|
10
|
-
# 4. restore into it: `home-hosted backup restore <name> --confirm`
|
|
10
|
+
# 4. restore into it: `home-hosted backup restore <name> --all --confirm`
|
|
11
11
|
# 5. start the entry on host B and read the database back
|
|
12
12
|
#
|
|
13
13
|
# Every step is a real command against a real panel and a real container. Nothing is faked, and the
|
|
@@ -91,7 +91,9 @@ note "declared the entry: docker run mongo:7, backupPaths = $DATA/dump"
|
|
|
91
91
|
|
|
92
92
|
say "Taking a backup"
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
# The plan first: what the archive would capture, written nothing.
|
|
95
|
+
HHOSTED_HOME="$HOST_A" "${CLI[@]}" backup create --all
|
|
96
|
+
HHOSTED_HOME="$HOST_A" "${CLI[@]}" backup create --all --confirm
|
|
95
97
|
ARCHIVE="$(HHOSTED_HOME="$HOST_A" "${CLI[@]}" backup list --json | node -e '
|
|
96
98
|
let raw = ""
|
|
97
99
|
process.stdin.on("data", chunk => raw += chunk)
|
|
@@ -137,7 +139,7 @@ cp "$HOST_A/.hh/.backups/$ARCHIVE" "$WORK/$ARCHIVE"
|
|
|
137
139
|
say "Planning the restore (nothing is written yet)"
|
|
138
140
|
mkdir -p "$HOST_B/.hh/.backups"
|
|
139
141
|
cp "$WORK/$ARCHIVE" "$HOST_B/.hh/.backups/$ARCHIVE"
|
|
140
|
-
HHOSTED_HOME="$HOST_B" "${CLI[@]}" backup restore "$ARCHIVE"
|
|
142
|
+
HHOSTED_HOME="$HOST_B" "${CLI[@]}" backup restore "$ARCHIVE" --all
|
|
141
143
|
rm -f "$HOST_B/.hh/.backups/$ARCHIVE"
|
|
142
144
|
curl -fsS -o /dev/null -X POST \
|
|
143
145
|
-H "Authorization: Bearer $SETUP_TOKEN" \
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "home-hosted",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.6",
|
|
5
5
|
"packageManager": "pnpm@12.5.1",
|
|
6
6
|
"description": "Self-hosted control panel that keeps your home-server processes alive: supervision, restarts, port conflicts, logs — and a UI you can replace.",
|
|
7
7
|
"author": "NamesMT <dangquoctrung123@gmail.com>",
|
|
@@ -72,17 +72,15 @@
|
|
|
72
72
|
"node": ">=24.0.0"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
75
|
+
"cli": "tsx src/cli.ts --home .dev-state",
|
|
76
|
+
"up": "pnpm run cli up",
|
|
77
|
+
"down": "pnpm run cli down",
|
|
78
|
+
"status": "pnpm run cli status",
|
|
79
|
+
"restart": "pnpm run cli restart",
|
|
80
|
+
"start": "pnpm run cli up --foreground",
|
|
80
81
|
"dev": "node scripts/dev.mjs",
|
|
81
82
|
"build": "pnpm run build:ui && pnpm run build:server",
|
|
82
83
|
"build:server": "vite build --config vite.server.config.ts",
|
|
83
|
-
"set-password": "tsx src/cli.ts set-password",
|
|
84
|
-
"set-token": "tsx src/cli.ts set-token",
|
|
85
|
-
"migrate": "tsx src/cli.ts migrate",
|
|
86
84
|
"lint": "eslint .",
|
|
87
85
|
"test:docs": "node scripts/check-doc-links.mjs",
|
|
88
86
|
"test": "vitest",
|
package/uis/stock/dist/ui.json
CHANGED