You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 39d4baa
Browse filesBrowse the repository at this point in the historyBrowse files
feat(database): back up, integrity-check and restore SQLite (SPEC-030)
SPEC-030 (cloud-storage#600), part 3 of 3 of SQLite support — the backend
is #598, the chart #599. Lightstack now ships for SQLite what an operator
gets from pg_dump on PostgreSQL: a consistent online backup, an integrity
check, and a documented restore and recovery procedure.
CLI (lightstack-migrate), SQLite only — both refuse a PostgreSQL URL and
name pg_dump:
- backup [<file>] runs VACUUM INTO for a consistent, standalone copy (no
-wal/-shm) taken while Lightstack keeps serving. The target is created
0600 before the copy and never overwrites an existing file; the default
is <state_path>/backups/lightstack-<UTC timestamp>.db.
- check runs PRAGMA integrity_check and exits non-zero listing the problems
on a damaged database. It also refuses a file that records no migration
version — an empty file passes SQLite's own check, and restoring one
would start Lightstack as a fresh install (FR-005a).
Restore and retention:
- MigrateUp refuses a database written by a newer Lightstack, naming both
versions, instead of golang-migrate's opaque "no migration found"
(FR-008). An older backup is migrated forward on start.
- BackupsDir sits beside db/, not inside it, and is absent from the
uninstall purge list, so dataRetentionPolicy: delete keeps backups —
they are the operator's (FR-004).
Tests and docs:
- backup/check are covered on real files (concurrent writer, existing-
target refusal, 0600/0750 modes, the wrong-order vs documented restore,
the non-Lightstack refusals); the CLI target resolution and the integrity
gate over a real golang-migrate schema are unit-tested.
- KUBERNETES_DEPLOYMENT.md and DOCKER_DEPLOYMENT.md document backup, restore
(delete -wal/-shm first) and recovery for a node debug pod and for
Compose; CONFIGURATION.md points at them. A host-testing runbook and
contracts live under docs/specs/030-sqlite-backup-restore/.
No new modules, no schema change, no migration.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -486,6 +486,8 @@ if requestedVersion == "" {
486
486
- PostgreSQL (unchanged) **or** one SQLite file chosen by the `database.url` scheme (`sqlite:///abs/path`, WAL, `synchronous=FULL`, 0600). One `migrations/` folder read through a per-backend view; SQLite starts at a generated `073_baseline.sqlite`; migration `074_reservation_node` (`volumes`/`snapshots.reserved_by`) on both (028-sqlite-database-layer)
487
487
- Helm 3.12+ chart (Go `text/template` + Sprig); JSON Schema **draft-07** (`values.schema.json`); Go 1.27.3 for the one `internal/teardown` change; Markdown docs. (029-sqlite-chart-compose)
488
488
- node-local hostPath SQLite directory at `<realMode.hostStoragePath>/db` (`lightstack.db` + `-wal` + `-shm`), **no PVC**. External PostgreSQL unchanged. **No schema change, no migration, no persisted data owned by the chart.** (029-sqlite-chart-compose)
- the operator's SQLite database file and a sibling `backups/` directory under the node storage root (`state_path` / `realMode.hostStoragePath`, default `/var/lib/lightstack`). **No schema change, no migration, no persisted data owned by the chart.** PostgreSQL is untouched except the backend-neutral ceiling check. (030-sqlite-backup-restore)
489
491
490
492
## Recent Changes
491
493
- 028-sqlite-database-layer: plan — SQLite as a second backend behind a backend-neutral `internal/database` contract whose method sets mirror pgx's, so the 736 call sites change types only. PostgreSQL passes SQL through untouched; SQLite translates casts, `= ANY($n)`, `FOR UPDATE` and the console expiry, registers `now()`/`gen_random_uuid()`/no-op advisory locks, and converts times, JSON, lists and `[]byte` (a STRICT TEXT column refuses BLOBs). Ten rewrite sites, the same for both backends; `name ~` stays a database match (`REGEXP` on SQLite), as upstream's. Cinder creates reserve a `creating` row and build the backing outside any transaction (+ a per-node startup sweep); Nova gains a binding quota recheck under an advisory lock and answers **403** instead of 413 (with FR-036a's 400s, the two API changes). Probe-verified: deferred read-then-write hits `SQLITE_BUSY_SNAPSHOT` (517) → immediate transactions expected (SPEC-028 plan)
0 commit comments