Implement the backup command (full account export via the CouchDB sync DB)#8
Open
byerun wants to merge 1 commit into
Open
Implement the backup command (full account export via the CouchDB sync DB)#8byerun wants to merge 1 commit into
byerun wants to merge 1 commit into
Conversation
Back up the entire account by dumping the CouchDB/Cloudant sync database directly, since the public API has no bulk-export endpoint. Output matches Marvin's GUI backup format (a JSON array of docs, with the internal _rev omitted except on conflicted records) and is written to MarvinBackup-<YYYYMMDD>.json by default. - Read all docs via _all_docs?include_docs=true&conflicts=true, paginated, with a per-request timeout and cross-page dedupe (live read, not a snapshot) - Strip _rev to match the GUI format; keep it on conflicted records as Marvin's marker and print a conflict warning - Add syncServer/syncDatabase/syncUser/syncPassword config keys and matching --sync-* flags (per-run alternative that keeps syncPassword out of config) - Move backup out of the desktop-only set: it talks to CouchDB directly, not the desktop or public API - Extract the CouchDB logic into backup_couch.ts with unit tests covering pagination, _design exclusion, _rev/_conflicts handling, dedupe, and grouping Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the previously-stubbed
backupcommand.Approach. The public API has no bulk-export endpoint, so this reads every document directly from the CouchDB/Cloudant sync database (
_all_docs?include_docs=true&conflicts=true, paginated). NewsyncServer/syncDatabase/syncUser/syncPasswordconfig keys (and--sync-*flags) supply the credentials from the API strategy page.Output. A JSON array of records →
MarvinBackup-<YYYYMMDD>.jsonby default (-o <file>, or-o -for stdout). It matches Marvin's GUI backup format:_revis stripped except on conflicted records (kept as Marvin's marker), and a conflict warning is printed. Equivalent to a GUI backup with "Device Local Settings/Data" unchecked — everything in the sync DB, minus non-synced device-local data (LocalStorageItems).Notes for reviewers:
backupis intentionally not desktop-gated (it talks to CouchDB directly), so it moved from DESKTOP COMMANDS to general COMMANDS.backup_couch.tswithdeno testcoverage. The repo's pre-existingerr.message-on-unknowntype errors are untouched; new code uses a small typed helper. Glad to promote it repo-wide if wanted.Testing done: read-only command (cannot modify an account); unit tests; run live against a ~1,550-record account and structurally compared to a GUI backup.
marvin backupfile restores cleanly via the GUI (including the_rev/conflict-marker handling)? This PR implements backup only;restoreremains the existing stub.