Phase 6 part 2: restore from a backup
A restore is staged (checked, the current database backed up) and swapped in when the app next starts. Settings → Backups restores with a self-restart, cancels a waiting restore, and takes uploads; supermarket restore takes a backup name or a file; supermarket backup --with-secrets makes an archive with the keys, for moving machines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1402,6 +1402,28 @@ in the WAL, as feared. The live database is 60 MB (mostly Stripe objects),
|
||||
so the backups folder holds about 620 MB; old legacy copies can be deleted
|
||||
from the page.
|
||||
|
||||
**Part 2 built (2026-11-22; no schema change).** A restore is staged,
|
||||
then applied on the next start, since a running app can't swap its own
|
||||
database: `backup.Stage` checks the file (integrity, a Supermarket
|
||||
database, schema no newer than the app's), backs up the current database
|
||||
(kind *restore*), and leaves `restore-pending.db` (plus
|
||||
`restore-pending.json`); `ApplyPending` runs in `main` before anything
|
||||
opens the database, re-checks it, removes the old `-wal`/`-shm`, renames
|
||||
it over `app.db`, and records `restore-done.json`; migrations then run as
|
||||
usual. From Settings → Backups, *Restore* (asks first) stages it and
|
||||
stops the app (`Server.Restart`, the signal context's cancel); Docker's
|
||||
`restart: unless-stopped` starts it again within a second, and the page
|
||||
reloads (a `Refresh` header). A staged restore can be cancelled until
|
||||
then. *Upload* takes a `.db` file, checks it and adds it to the list as
|
||||
one of the user's backups. `supermarket restore <name or file>` copies a
|
||||
host file into the data folder, stages it in the container, and restarts
|
||||
the app. `supermarket backup --with-secrets` writes a mode-0600
|
||||
`app-<time>-with-secrets.tar.gz` (app.db, secrets.json, mcp-token) to the
|
||||
backups folder, not listed on the page; restoring one replaces
|
||||
secrets.json too (the old one kept in the backups folder), while this
|
||||
machine's mcp-token stays. Tried live both ways (the command line and the
|
||||
page) by restoring a backup taken seconds before.
|
||||
|
||||
### Future enhancements
|
||||
|
||||
Not in any phase yet; picked up when the user asks.
|
||||
|
||||
Reference in New Issue
Block a user