Skip to content

[data-safety] Snapshot the local database before a release's migrations run (no data loss on update) #1887

Closed

Description

@mstomar125

Why

A prospective client is evaluating NodeSpace and their stated blocker is data loss / backup on release. We need a concrete guarantee that installing a new release cannot lose a user's existing data.

Existing guarantees

  • The local store lives in ~/.nodespace/ (daemon-pro-db / database/nodespace.db), outside the .app bundle — replacing/reinstalling the app never touches it.
  • Migrations are versioned (PRAGMA user_version) and each runs in its own transaction — a crash mid-migration leaves a consistent, re-resumable database.

Gap

The transactional safety covers a crash mid-migration, not a committed migration that is semantically destructive or buggy (a risk that grows as future releases add non-additive migrations). There is no pre-release snapshot to recover from.

Fix

Before any pending migration runs (user_version in (0, LATEST_VERSION)), snapshot the DB file — WAL-checkpointed for a consistent single-file copy — into a backups/ sibling directory, pruned to the last few. Best-effort: a backup failure is logged and never blocks startup (today's migrations are additive; this is defense in depth for future ones). Wired into SqliteStore::new.

This is the data-safety half of the auto-update manager (the notification half is #1321). Restore for v1 is copying the .bak back; restore tooling is a follow-up.

Activity

  1. mstomar125 commented on Aug 1, 2026

    @mstomar125
    ContributorAuthor

    Resolved in #1889 (merged). SqliteStore::new now takes a VACUUM INTO consistent snapshot of the DB before any pending migration runs (gated on real data; nanos+pid filenames; pruned to 5; best-effort). Live-validated on a real 185-node v2 profile: the daemon snapshotted (v2/185) then migrated the live db to v3. Three-layer guarantee complete: data outside the bundle + transactional migrations + pre-release snapshot. v1 restore = copy the .bak back (valid standalone SQLite db); restore tooling is a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions