An app's encrypted backup, with a restore proof (#11701)

The forge's backup (backup-truth.md) covers the forge. An app's data (FORGE_APP_DATA: its SQLite files and uploads) gets a backup the owner holds the key to, and a restore that proves itself.

export APP_BACKUP_PASSPHRASE='…at least 12 characters, kept off the forge…'
bun scripts/app-backup.ts seal <data-dir> <out-file>
bun scripts/app-backup.ts prove <out-file> <empty-scratch-dir>

In the terminal

An admin of an app opens : → "Back up data" (src/tui/screens/appbackup.ts). s asks for the passphrase (masked) and seals the app's production data into <forge data>/app-backups/<app id>/production-<time>.fab, proving it and the data left behind as above; p proves the file under the cursor. The screen shows the same PROVEN or RED lines as the script. The file is encrypted under a key only the owner holds; copy it off the forge to keep it. The seal and the proof run src/apps/backup_cli.ts (the code behind scripts/app-backup.ts) in a child process (the passphrase in its environment, never in argv), so the forge's event loop stays free. There is no size cap: before a byte is read, the screen checks the disk has room for the archive and its proof restore (the data's size each, added up when they share a disk, plus 64 MB to spare; a proof needs the backup's size in the temp directory) and otherwise refuses in one sentence: not enough disk space: this needs about N MB and M MB are free. Logic: src/apps/backup_door.ts; tests: test/tui-appbackup.test.ts.

Not done: the seal still reads each file twice (hash, then encrypt) and the proof decrypts twice (tag, then restore), trading time for flat memory; no scheduled backup, no upload to a bucket, and no web page button; the terminal seals production data only, not previews.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs