Skip to content

Epic: D1 backup, restore & local-run harness (expands #655) #794

Closed
4 of 4 issues completed
Closed

Description

@neuromechanist

Expands #655 (Database backup). Arnaud's ask: "Cloudflare database could be hacked or corrupted. We should back it up regularly."

Goal

A private repo (nemarOrg/nemar-db-backup) that hourly (GitHub Actions cron) backs up the prod D1 (nemar-db) to plaintext .sql committed to git history (point-in-time recovery), is restorable for disaster recovery, and is good enough to run the Worker locally as a fallback to remote CF deployment with minimal change.

Locked decisions (2026-06-18)

  • New PRIVATE repo nemarOrg/nemar-db-backup (nemar-cli is PUBLIC; dumps contain user emails + argon2 password hashes).
  • Scope: prod D1 nemar-db only. Vectorize is derived (id-only, rebuildable via reindex); Analytics Engine is telemetry. Neither is backed up.
  • Plaintext .sql in the private repo (git delta-compresses hourly snapshots; one-command local run). No encryption layer.
  • Hourly cron; commit only when changed.

Key constraint (verified live)

wrangler d1 export refuses any DB containing an fts5 virtual table (cannot export databases with Virtual Tables (fts5)) — full, --no-schema, and --no-data all fail. Bypass: per-table --table <name> allowlist works. So we export each real table individually, capture schema from sqlite_master, and recreate datasets_fts + triggers on restore. Full research: .context/research-d1-backup-655.md.

Phases

  1. Core self-verifying backup script (per-table export -> schema.sql + data.sql + manifest.json + round-trip verify).
  2. Hourly GitHub Actions cron + commit-if-changed + repo scaffolding (README, .gitignore, secrets doc).
  3. Restore (disaster recovery) + run-local harness + docs.

Code ships as phase PRs in nemarOrg/nemar-db-backup; nemar-cli carries the research context + a disaster-recovery pointer doc.

Sub-issues

Sub-issues

4 of 4 Issues completed
Loading 4 sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions