diff --git a/PLAN.md b/PLAN.md index 655a498..5f289fb 100644 --- a/PLAN.md +++ b/PLAN.md @@ -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 ` 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-