@jamiefutch/pi-backup 1.1.10 → 1.1.12
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 +83 -31
- package/backup-manifest.txt +61 -0
- package/backup-pi.ps1 +171 -117
- package/backup-pi.sh +166 -135
- package/extensions/pi-backup-manager.ts +237 -85
- package/package.json +6 -4
- package/pi-clean-reinstall.ps1 +79 -17
- package/pi-clean-reinstall.sh +81 -26
- package/restore-pi.ps1 +144 -105
- package/restore-pi.sh +102 -107
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ Opens the **Pi Backup Manager** interactive menu:
|
|
|
75
75
|
|
|
76
76
|
```
|
|
77
77
|
Pi Backup Manager — 8 backups (1 internal, 7 external)
|
|
78
|
-
External dir: ~/
|
|
78
|
+
External dir: ~/pi-backups
|
|
79
79
|
|
|
80
80
|
→ 📦 Create internal backup (~/.pi/backups/ — quick rollback)
|
|
81
81
|
💾 Create external backup (survives reinstall)
|
|
@@ -125,8 +125,8 @@ Backup: pi-backup-20260812-112019.7z
|
|
|
125
125
|
|
|
126
126
|
| Action | Description |
|
|
127
127
|
|--------|-------------|
|
|
128
|
-
| **🔄 Restore** |
|
|
129
|
-
| **📋 Copy to internal** |
|
|
128
|
+
| **🔄 Restore** | After confirmation, shows (and copies, where possible) the exact restore command to run **after you exit Pi**. The TUI never restores in-process, because the running Pi owns the files being replaced |
|
|
129
|
+
| **📋 Copy to internal** | Extracts/copies an external backup into `~/.pi/backups/` as an uncompressed directory (external only) |
|
|
130
130
|
| **📄 View manifest** | Opens `MANIFEST.txt` in editor (extracts from compressed archives) |
|
|
131
131
|
| **🗑️ Delete** | Permanently removes backup (requires confirmation) |
|
|
132
132
|
|
|
@@ -135,7 +135,7 @@ Backup: pi-backup-20260812-112019.7z
|
|
|
135
135
|
| Location | Path | Survives Clean Reinstall? | Format |
|
|
136
136
|
|----------|------|---------------------------|--------|
|
|
137
137
|
| **Internal** | `~/.pi/backups/` | ❌ NO (wiped by `rm -rf ~/.pi`) | Uncompressed dirs |
|
|
138
|
-
| **External** | `~/
|
|
138
|
+
| **External** | `~/pi-backups/` | ✅ YES | Compressed (.7z/.zip) |
|
|
139
139
|
|
|
140
140
|
> **Key point**: Always create an **external backup** before a clean reinstall. Internal backups are for quick rollbacks during normal use only.
|
|
141
141
|
|
|
@@ -143,19 +143,29 @@ Backup: pi-backup-20260812-112019.7z
|
|
|
143
143
|
|
|
144
144
|
#### 1. Backup (before reinstall)
|
|
145
145
|
```bash
|
|
146
|
-
|
|
146
|
+
./backup-pi.sh
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
#### 2. Clean Reinstall
|
|
150
150
|
```bash
|
|
151
|
-
|
|
151
|
+
./pi-clean-reinstall.sh
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
The clean reinstall is rollback-safe: it checks that a backup exists in `BACKUP_ROOT` (and asks for an extra `no backup` confirmation if not), **moves** `~/.pi` to `~/.pi.pre-reinstall-<timestamp>`, uninstalls and reinstalls Pi, verifies `pi --version`, and only then deletes the moved copy. If any step fails, the original `~/.pi` is moved back. Set `KEEP_OLD=1` to keep the moved-aside copy.
|
|
155
|
+
|
|
154
156
|
#### 3. Restore a directory, `.7z` archive, or `.zip` archive
|
|
155
157
|
```bash
|
|
156
|
-
|
|
158
|
+
./restore-pi.sh ~/pi-backups/pi-backup-20260811-143000.7z
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Exit Pi first: the script warns (but does not block) if it detects a running Pi process, because files restored under a running Pi can be overwritten when it exits. Restore asks for confirmation; it needs an interactive terminal and otherwise stops with a message. For scripted use, set `PI_BACKUP_ASSUME_YES=1`:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
PI_BACKUP_ASSUME_YES=1 ./restore-pi.sh ~/pi-backups/pi-backup-20260811-143000.7z
|
|
157
165
|
```
|
|
158
166
|
|
|
167
|
+
Temporary extraction directories are always removed, including when you answer `n`, the archive is damaged, or a copy fails part-way.
|
|
168
|
+
|
|
159
169
|
#### 4. Reinstall npm deps + verify
|
|
160
170
|
```bash
|
|
161
171
|
cd ~/.pi/agent && npm install # or bun install
|
|
@@ -167,7 +177,7 @@ pi --version
|
|
|
167
177
|
|
|
168
178
|
### Windows (PowerShell)
|
|
169
179
|
|
|
170
|
-
On Windows, use the `.ps1` scripts from PowerShell 7 (`pwsh`). The backup data directory defaults to `~/
|
|
180
|
+
On Windows, use the `.ps1` scripts from PowerShell 7 (`pwsh`). The backup data directory defaults to `~/pi-backups`.
|
|
171
181
|
|
|
172
182
|
```powershell
|
|
173
183
|
# 1. Backup (before reinstall)
|
|
@@ -177,7 +187,7 @@ On Windows, use the `.ps1` scripts from PowerShell 7 (`pwsh`). The backup data d
|
|
|
177
187
|
.\pi-clean-reinstall.ps1
|
|
178
188
|
|
|
179
189
|
# 3. Restore
|
|
180
|
-
.\restore-pi.ps1 ~\
|
|
190
|
+
.\restore-pi.ps1 ~\pi-backups\pi-backup-20260811-143000
|
|
181
191
|
|
|
182
192
|
# 4. Reinstall npm deps + verify
|
|
183
193
|
cd ~\.pi\agent; npm install
|
|
@@ -195,31 +205,52 @@ $env:PI_ROOT='C:\Users\you\.pi'; $env:BACKUP_ROOT='D:\pi-backups'; .\backup-pi.p
|
|
|
195
205
|
|
|
196
206
|
## What Gets Backed Up
|
|
197
207
|
|
|
208
|
+
The list lives in one file, [`backup-manifest.txt`](backup-manifest.txt), read by all four scripts; a test keeps this table in sync with it.
|
|
209
|
+
|
|
198
210
|
| Category | Paths |
|
|
199
211
|
|----------|-------|
|
|
200
212
|
| **Core config** | `settings.json`, `auth.json`, `models.json`, `trust.json`, `keybindings.json`, `pix.json`, `optimizer.json`, `lmstudio.json.bak`, `hermes-memory-config.json`, `pi.code-workspace` |
|
|
201
213
|
| **Extension configs** | `pi-hermes-memory-cleanup/scoped-memory.json`, `loop-police.json`, `pi-rtk/config.json`, `context-mode/config.json`, `pi-timeout/config.json`, `pi-context-viewer/config.json`, `pix-optimizer/config.json`, `pi-nvidia-nim/config.json` |
|
|
202
214
|
| **Global skills** | `~/.pi/agent/skills/` |
|
|
203
215
|
| **Project skills & memory** | `~/.pi/agent/projects-memory/<project>/` |
|
|
204
|
-
| **Local extension source** |
|
|
205
|
-
| **npm manifests** | `package.json`, `package-lock.json`, `npm-shrinkwrap.json` from `~/.pi/agent/npm/` |
|
|
206
|
-
| **Hermes memory (active)** | `MEMORY.md`, `USER.md`, `failures.md`, `retired
|
|
207
|
-
| **Cleanup backups** | Last 5 from `~/.pi/agent/hermes-cleanup/` |
|
|
216
|
+
| **Local extension source** | `$LOCAL_EXT_ROOT/pi-timeout/`, `pi-chunk/`, `pi-hermes-memory-cleanup/`, `pi-context-docs/` (defaults to `~/projects/`; `node_modules`, `dist`, `build`, `.git`, `coverage` and `*.log` are skipped) |
|
|
217
|
+
| **npm manifests** | `package.json`, `package-lock.json`, `npm-shrinkwrap.json`, `pnpm-lock.yaml` from `~/.pi/agent/npm/` (never `node_modules`) |
|
|
218
|
+
| **Hermes memory (active)** | `MEMORY.md`, `USER.md`, `failures.md`, `retired-failures.md`, `retired-memory.md` |
|
|
219
|
+
| **Cleanup backups** | Last 5 timestamped (`20*`) directories from `~/.pi/agent/hermes-cleanup/` |
|
|
208
220
|
|
|
209
|
-
|
|
221
|
+
Example output of `./backup-pi.sh` (captured from a real run, abridged):
|
|
210
222
|
```
|
|
211
|
-
════════════════════════════════════════════════════════════
|
|
212
|
-
|
|
213
|
-
════════════════════════════════════════════════════════════
|
|
214
|
-
Source:
|
|
215
|
-
Destination: ~/
|
|
223
|
+
[INFO] ════════════════════════════════════════════════════════════
|
|
224
|
+
[INFO] Pi Complete Backup
|
|
225
|
+
[INFO] ════════════════════════════════════════════════════════════
|
|
226
|
+
[INFO] Source: ~/.pi
|
|
227
|
+
[INFO] Destination: ~/pi-backups/pi-backup-20261122-011819
|
|
228
|
+
|
|
229
|
+
[INFO] 1/8 Core configuration files...
|
|
230
|
+
[OK] settings.json
|
|
231
|
+
[OK] auth.json
|
|
232
|
+
[WARN] auth.json holds your API credentials and is included in this backup.
|
|
233
|
+
[WARN] Keep the backup private; set PI_BACKUP_EXCLUDE_AUTH=1 to leave it out.
|
|
234
|
+
[OK] models.json
|
|
235
|
+
[WARN] keybindings.json — not found, skipping
|
|
216
236
|
...
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
237
|
+
[INFO] 8/8 Recent hermes-cleanup backups (last 5)...
|
|
238
|
+
[OK] 20260107/
|
|
239
|
+
...
|
|
240
|
+
[INFO] 9/9 Compressing backup (zip)...
|
|
241
|
+
[OK] ~/pi-backups/pi-backup-20261122-011819.zip
|
|
242
|
+
|
|
243
|
+
[INFO] ════════════════════════════════════════════════════════════
|
|
244
|
+
[OK] Backup complete!
|
|
245
|
+
[INFO] Archive: ~/pi-backups/pi-backup-20261122-011819.zip
|
|
246
|
+
[INFO] Size: 12K
|
|
247
|
+
|
|
248
|
+
[INFO] To restore after reinstall:
|
|
249
|
+
[INFO] ./restore-pi.sh ~/pi-backups/pi-backup-20261122-011819.zip
|
|
221
250
|
```
|
|
222
251
|
|
|
252
|
+
An internal backup (`KEEP_UNCOMPRESSED=1`, what the TUI's **Create internal backup** runs) skips the compression step and prints `Staging: <directory>` instead of `Archive:`.
|
|
253
|
+
|
|
223
254
|
## What Does NOT Get Backed Up (Regeneratable)
|
|
224
255
|
|
|
225
256
|
| Excluded | Why |
|
|
@@ -232,10 +263,22 @@ Files: 347
|
|
|
232
263
|
|
|
233
264
|
---
|
|
234
265
|
|
|
266
|
+
## Security
|
|
267
|
+
|
|
268
|
+
> **Backups contain `auth.json`, which holds your API keys and tokens.** Treat every backup (directory, `.zip`, `.7z`) as a secret.
|
|
269
|
+
|
|
270
|
+
- Backups are created private to your user: `umask 077` on macOS/Linux, `auth.json` is `chmod 600`, and archives are `600` (on Windows, rely on your profile folder's ACLs and avoid shared drives).
|
|
271
|
+
- Set `PI_BACKUP_EXCLUDE_AUTH=1` to leave `auth.json` out entirely (you will need to sign in to providers again after a restore).
|
|
272
|
+
- Restore sets a restored `auth.json` back to `600`.
|
|
273
|
+
- There is intentionally no built-in encryption: passing a password to `7z` on the command line leaks it through `ps`. If you need encryption, encrypt the finished archive yourself (for example with `age` or `gpg`) or store backups on an encrypted volume.
|
|
274
|
+
- Never commit or share backups. They are also in `.gitignore` (`*.7z`, `*.zip`, `backups/`).
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
235
278
|
## Backup Location
|
|
236
279
|
|
|
237
280
|
```
|
|
238
|
-
~/
|
|
281
|
+
~/pi-backups/
|
|
239
282
|
├── pi-backup-20260811-143000/
|
|
240
283
|
│ ├── MANIFEST.txt
|
|
241
284
|
│ ├── settings.json
|
|
@@ -261,7 +304,7 @@ The external backup location is resolved in this priority order:
|
|
|
261
304
|
|
|
262
305
|
1. **`BACKUP_ROOT`** environment variable (highest priority)
|
|
263
306
|
2. **`externalBackupDir`** key in `~/.pi/agent/settings.json`
|
|
264
|
-
3. **Default**: `~/
|
|
307
|
+
3. **Default**: `~/pi-backups/`
|
|
265
308
|
|
|
266
309
|
```json
|
|
267
310
|
// ~/.pi/agent/settings.json
|
|
@@ -277,6 +320,8 @@ Use the **⚙️ Configure external backup directory** option in `/pi-backup` to
|
|
|
277
320
|
- **📝 Change directory** — prompt to type a path, saved to `settings.json`
|
|
278
321
|
- **🔄 Reset to default** — removes the `settings.json` value, falls back to env var / default
|
|
279
322
|
|
|
323
|
+
If `settings.json` is corrupt (not valid JSON), the manager never overwrites it: read-only screens fall back to the default directory with one warning, and changes are refused with an error. Successful saves are written atomically and keep the previous file as `settings.json.bak-<timestamp>` (last 3 kept).
|
|
324
|
+
|
|
280
325
|
### When the prompt appears
|
|
281
326
|
|
|
282
327
|
The configure prompt only appears when creating an external backup if **both** of these are true:
|
|
@@ -292,13 +337,17 @@ If the default directory already contains backups, it is treated as configured a
|
|
|
292
337
|
| Variable | Default | Purpose |
|
|
293
338
|
|----------|---------|---------|
|
|
294
339
|
| `PI_ROOT` | `~/.pi` | Override Pi root directory |
|
|
295
|
-
| `BACKUP_ROOT` | `~/
|
|
296
|
-
| `
|
|
340
|
+
| `BACKUP_ROOT` | `~/pi-backups` | Override backup destination (highest priority for the TUI too) |
|
|
341
|
+
| `LOCAL_EXT_ROOT` | `~/projects` | Override the directory containing local extension source repositories |
|
|
342
|
+
| `KEEP_UNCOMPRESSED` | `0` | `1` makes a plain, uncompressed staging directory and skips compression (no `zip`/7-Zip needed); the TUI sets this for internal backups. With `0` the staging directory is compressed and removed |
|
|
343
|
+
| `PI_BACKUP_ASSUME_YES` | unset | Set to `1` to skip the restore confirmation prompt (scripted use). Without it, restore needs an interactive terminal and exits with a clear message otherwise |
|
|
344
|
+
| `PI_BACKUP_EXCLUDE_AUTH` | unset | Set to `1` to leave `auth.json` (API credentials) out of the backup |
|
|
345
|
+
| `KEEP_OLD` | unset | Set to `1` to keep `~/.pi.pre-reinstall-<timestamp>` after a successful clean reinstall |
|
|
297
346
|
| `PKG_MANAGER` | `bun` | Package manager used by the clean-reinstall scripts (`bun`, `npm`, etc.) |
|
|
298
347
|
|
|
299
348
|
```bash
|
|
300
349
|
# Custom locations
|
|
301
|
-
PI_ROOT=/custom/.pi BACKUP_ROOT=/mnt/backups
|
|
350
|
+
PI_ROOT=/custom/.pi BACKUP_ROOT=/mnt/backups ./backup-pi.sh
|
|
302
351
|
```
|
|
303
352
|
|
|
304
353
|
---
|
|
@@ -307,10 +356,10 @@ PI_ROOT=/custom/.pi BACKUP_ROOT=/mnt/backups ~/projects/personal/pi-backup/backu
|
|
|
307
356
|
|
|
308
357
|
```bash
|
|
309
358
|
# Daily backup at 3 AM
|
|
310
|
-
0 3 * * *
|
|
359
|
+
0 3 * * * ./backup-pi.sh >> ~/pi-backup.log 2>&1
|
|
311
360
|
|
|
312
361
|
# Keep last 30 backups
|
|
313
|
-
0 4 * * * find ~/
|
|
362
|
+
0 4 * * * find ~/pi-backups -maxdepth 1 -type d -name 'pi-backup-*' -mtime +30 -exec rm -rf {} \;
|
|
314
363
|
```
|
|
315
364
|
|
|
316
365
|
---
|
|
@@ -323,7 +372,10 @@ PI_ROOT=/custom/.pi BACKUP_ROOT=/mnt/backups ~/projects/personal/pi-backup/backu
|
|
|
323
372
|
| "npm install fails" | Check Node.js version (need ≥22), try `bun install` |
|
|
324
373
|
| "Skills not loading" | Verify `settings.json` has correct `packages` paths after restore |
|
|
325
374
|
| "Models not found" | Check `models.json` restored correctly, restart Pi |
|
|
326
|
-
| "Auth failed" | Verify `auth.json` restored, API keys valid |
|
|
375
|
+
| "Auth failed" | Verify `auth.json` restored, API keys valid (it is absent if the backup was made with `PI_BACKUP_EXCLUDE_AUTH=1`) |
|
|
376
|
+
| Restore says "Cannot read a confirmation" | stdin is not a terminal (cron, CI, pipe). Run it in a terminal or set `PI_BACKUP_ASSUME_YES=1` |
|
|
377
|
+
| Backup says "Compression ... failed" | The staging directory is kept (it is intact). Fix 7-Zip/zip and re-run, or restore directly from the staging directory |
|
|
378
|
+
| TUI says `settings.json could not be parsed` | The file is never overwritten. Fix the JSON (or delete the file) and retry; `settings.json.bak-*` copies are kept from earlier saves |
|
|
327
379
|
|
|
328
380
|
---
|
|
329
381
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# pi-backup manifest: the single source of truth for what is backed up and restored.
|
|
2
|
+
# Read by backup-pi.sh, restore-pi.sh, backup-pi.ps1 and restore-pi.ps1.
|
|
3
|
+
# LF line endings only (enforced by .gitattributes). Paths use "/" on every platform.
|
|
4
|
+
# Paths on the left are relative to PI_ROOT (default ~/.pi); the right side is relative to the backup.
|
|
5
|
+
#
|
|
6
|
+
# section|<title> starts a numbered step in the script output
|
|
7
|
+
# file|<pi path>|<backup path> one file; missing files are skipped with a warning
|
|
8
|
+
# dir|<pi path>|<backup path> a whole directory; replaced on restore
|
|
9
|
+
# dir-each|<pi path>|<backup path> each sub-directory is backed up / replaced separately
|
|
10
|
+
# local-ext|<name> source tree under LOCAL_EXT_ROOT (node_modules, dist, build, .git, coverage, *.log excluded)
|
|
11
|
+
# npm|<pi path>|<backup path> package.json and lockfiles only (max depth 3), never node_modules
|
|
12
|
+
# recent|<pi path>|<backup path>|<n> the n newest sub-directories whose name starts with "20" (timestamps)
|
|
13
|
+
#
|
|
14
|
+
# Keep README.md "What Gets Backed Up" in sync; tests/sh/manifest.test.sh checks it.
|
|
15
|
+
|
|
16
|
+
section|Core configuration files
|
|
17
|
+
file|agent/settings.json|settings.json
|
|
18
|
+
file|agent/auth.json|auth.json
|
|
19
|
+
file|agent/models.json|models.json
|
|
20
|
+
file|agent/trust.json|trust.json
|
|
21
|
+
file|agent/keybindings.json|keybindings.json
|
|
22
|
+
file|agent/pix.json|pix.json
|
|
23
|
+
file|agent/optimizer.json|optimizer.json
|
|
24
|
+
file|agent/lmstudio.json.bak|lmstudio.json.bak
|
|
25
|
+
file|agent/hermes-memory-config.json|hermes-memory-config.json
|
|
26
|
+
file|agent/pi.code-workspace|pi.code-workspace
|
|
27
|
+
|
|
28
|
+
section|Extension configurations
|
|
29
|
+
file|agent/pi-hermes-memory-cleanup/scoped-memory.json|pi-hermes-memory-cleanup/scoped-memory.json
|
|
30
|
+
file|agent/loop-police.json|loop-police.json
|
|
31
|
+
file|agent/pi-rtk/config.json|pi-rtk/config.json
|
|
32
|
+
file|agent/context-mode/config.json|context-mode/config.json
|
|
33
|
+
file|agent/pi-timeout/config.json|pi-timeout/config.json
|
|
34
|
+
file|agent/pi-context-viewer/config.json|pi-context-viewer/config.json
|
|
35
|
+
file|agent/pix-optimizer/config.json|pix-optimizer/config.json
|
|
36
|
+
file|agent/pi-nvidia-nim/config.json|pi-nvidia-nim/config.json
|
|
37
|
+
|
|
38
|
+
section|Global skills
|
|
39
|
+
dir|agent/skills|skills
|
|
40
|
+
|
|
41
|
+
section|Project skills & memory
|
|
42
|
+
dir-each|agent/projects-memory|projects-memory
|
|
43
|
+
|
|
44
|
+
section|Local extension source code
|
|
45
|
+
local-ext|pi-timeout
|
|
46
|
+
local-ext|pi-chunk
|
|
47
|
+
local-ext|pi-hermes-memory-cleanup
|
|
48
|
+
local-ext|pi-context-docs
|
|
49
|
+
|
|
50
|
+
section|npm extension manifests
|
|
51
|
+
npm|agent/npm|npm-manifests
|
|
52
|
+
|
|
53
|
+
section|Hermes memory (active files)
|
|
54
|
+
file|agent/pi-hermes-memory/MEMORY.md|pi-hermes-memory/MEMORY.md
|
|
55
|
+
file|agent/pi-hermes-memory/USER.md|pi-hermes-memory/USER.md
|
|
56
|
+
file|agent/pi-hermes-memory/failures.md|pi-hermes-memory/failures.md
|
|
57
|
+
file|agent/pi-hermes-memory/retired-failures.md|pi-hermes-memory/retired-failures.md
|
|
58
|
+
file|agent/pi-hermes-memory/retired-memory.md|pi-hermes-memory/retired-memory.md
|
|
59
|
+
|
|
60
|
+
section|Recent hermes-cleanup backups (last 5)
|
|
61
|
+
recent|agent/hermes-cleanup|hermes-cleanup|5
|