Skip to content

D1 backup, restore & local-run harness (expands #655) - #798

Merged
neuromechanist merged 2 commits into
devfrom
feature/issue-794-epic-d1-backup
Jun 18, 2026
Merged

neuromechanist merged 2 commits into
devfrom
feature/issue-794-epic-d1-backup

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Epic deliverable for #655. The backup system itself lives in the new private repo
nemarOrg/nemar-db-backup (3 phase PRs, each
reviewed). This nemar-cli PR carries only the supporting docs:

  • .context/research-d1-backup-655.md - research + locked decisions + the verified fts5/NUL/sequence findings.
  • AGENTS.md - a "Database backup & disaster recovery" pointer (where backups live, the fts5 gotcha, how to restore / run locally).

What shipped in nemar-db-backup

  • Hourly GitHub Actions cron backs up prod D1 (nemar-db) to deterministic plaintext SQL,
    committing only when schema/data change (git history = point-in-time recovery).
  • Self-verifying: every backup is restored into a throwaway SQLite and row/fts5/FK-checked before publishing.
  • fts5 workaround (per-table export), sqlite_sequence preservation, NUL-byte lossless encoding.
  • restore-remote.sh (guarded disaster recovery, validated into a throwaway D1) + run-local.sh
    (local miniflare D1 + wrangler dev).
  • Proprietary LICENSE (internal use only) + initial prod snapshot (4059 rows) committed.

Phases (all merged + reviewed)

  1. nemar-db-backup#1 - core self-verifying backup script (closes Phase 1: Core self-verifying D1 backup script #795)
  2. nemar-db-backup#2 - hourly cron + scaffolding (closes Phase 2: Hourly GitHub Actions backup cron + repo scaffolding #796)
  3. nemar-db-backup#3 - restore + run-local + docs (closes Phase 3: Restore (disaster recovery) + run-local harness + docs #797)

Follow-up (owner)

Add repo secrets to nemar-db-backup to activate the hourly cron: CLOUDFLARE_API_TOKEN
(recommend a scoped D1:Edit token) + CLOUDFLARE_ACCOUNT_ID.

Closes #794. Expands #655.

@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR798

Version: 0.8.61-PR798.0e24b72
Commit: 0e24b72


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 5695cfa into dev Jun 18, 2026
10 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-794-epic-d1-backup branch June 18, 2026 19:11

This branch was previously deployed

1 inactive deployment
npm — 0e24b72c Deployed Jun 18, 2026 by neuromechanist via publish #1480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant