mongodb: add importer/exporter integration - #78
Open
Abdul-Moiz31 wants to merge 1 commit into
Open
Conversation
Author
|
Following up on the MongoDB integration we discussed over Discord. This PR implements the scope you approved: single-database logical backup/restore via Ran the full test suite locally, including the testcontainers e2e roundtrip against real MongoDB containers , passes end to end. Happy to adjust anything that doesn't match what you had in mind for v1. Looking forward !! |
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.
New integration for MongoDB: back up a single logical database via
mongodump/mongorestore --archiveand restore it to any MongoDB server. Everything lives undermongodb/, in the same family as the existingpostgresqlandmysqlconnectors.Discussed with @Mathieu-PLKR over Discord — scope (logical dump/restore only,
mongodb://URI scheme) confirmed before implementation.What it does
mongodb://[user:pass@]host[:port]/database): wrapsmongodump --archive, streamed directly as a single record (/dump.archive) rather than written to a temp file first, plus a lightweight/manifest.json(host, port, database,mongodumpversion — no live server introspection in v1).mongorestore --archive, reading straight from the record'sio.Reader. Supportsdrop(maps tomongorestore --drop) as the closest equivalent to Postgres'scleanoption.Options
Connection:
location(mongodb://URI) or standalonehost/port/username/password/databaseoverrides, same override pattern as postgresql's schema.tls/tls_ca_filefor TLS.mongo_bin_dirto point at a non-$PATHinstall of the MongoDB database tools. A database (vialocationpath ordatabasekey) is required in v1 — enforced both in the JSON schema (anyOf: [location, database]) and at runtime.Credentials are never placed on the
mongodump/mongorestorecommand line — the connection URI (including password) is written to a0600temp--configYAML file instead, mirroring how postgresql injectsPGPASSWORDvia env and mysql uses--defaults-extra-file.Explicitly out of scope for v1
--nsInclude/--nsExcludecollection filtering, oplog/point-in-time restore, sharded-cluster flags, Atlas-specific auth,mongodb+srv://(all noted as fast-follows, not blockers).Validation
go build ./...,go vet ./...,go mod tidy— cleanmake build— bothmongodbImporterandmongodbExporterbuild successfullytests/logical/single_test.go) run against live Docker: seeds amongo:7source, backs it up viamongodb://.../testdb, verifies the snapshot contains/dump.archive+/manifest.json, restores into a freshmongo:7target, and confirms the document count matches — full roundtrip passes.