Skip to main content
Menu

MongoDB to DocumentDB

Live migration from MongoDB to Azure DocumentDB

Use Dsync to move from MongoDB to Azure DocumentDB while production keeps serving. DocumentDB is open source and MongoDB-compatible, so the application usually does not change.

What actually changes between MongoDB and Azure DocumentDB

Azure DocumentDB is an open-source, MongoDB-compatible database built on PostgreSQL, with the MongoDB wire protocol and query language implemented as extensions. Microsoft runs it as the managed service previously branded Cosmos DB for MongoDB vCore, it can also be self-hosted, and since the project moved under the Linux Foundation the compatibility gap has been closing quickly. It is still a different engine underneath: storage, indexing and transaction behavior are PostgreSQL's, and a few MongoDB features — some aggregation stages, certain index types, particular write-concern semantics — are either implemented differently or not yet at all.

That is what makes the migration a validation exercise as much as a data movement one. The safe sequence is to stand up DocumentDB, replicate production into it continuously, and run the application's real query load against the replica while MongoDB remains the system of record — which surfaces any incompatibility with real data and real traffic rather than a test fixture. Dsync provides the continuous replication: a parallel, resumable initial copy followed by oplog tailing, with verification comparing the two sides as it goes, in a single process with no broker or staging in the data path.

Because DocumentDB is supported as a source as well, the same setup works in the other direction. Teams use that to keep MongoDB current for a period after cutover so the back-out is a reversal rather than a restore, and to move between the managed and self-hosted forms of DocumentDB later without a second migration project.

Why MongoDB to DocumentDB is harder than it looks

The usual approach

  • mongodump and mongorestore need a write freeze for the whole restore
  • Atlas Live Migrate and mongosync do not target DocumentDB
  • Kafka-based DIY takes weeks to months of setup, orchestration and custom code
  • Index and feature differences between MongoDB and DocumentDB surface after cutover, not before
  • Testing DocumentDB against real traffic means a second, hand-maintained copy of production

With Dsync

  • The MongoDB replica set keeps serving traffic throughout
  • Initial copy is partitioned and parallel, and resumes from its checkpoint after an interruption
  • The MongoDB oplog is followed alongside the copy, so writes during the migration land once
  • DocumentDB is supported as both a destination and a source — the managed Azure service and the open-source build
  • Verification is a flag, quick count or full hash comparison, and the reverse run is the back-out

How the migration runs

dsync $MONGO $DOCUMENTDB
  1. 01

    Parallelized, resumable initial copy

    • 10–100× faster than scripts
    • Resumes from checkpoint
    • Progress via CLI or web UI
  2. 02

    Real-time incremental sync and CDC

    • 1000+ ops/sec on active workloads
    • Automatic resume after interruption
    • Seamless handover from the copy
  3. 03

    Verified cutover

    • No downtime out of the box
    • Embedded integrity checks
    • Back out by reversing direction

See it running

What a migration actually looks like

Not a mockup. The command line, the web UI and the integrity check, from a real run.

The dsync command-line interface during a migration, showing per-collection progress and throughput.
Command line — progress, throughput and lag per namespace, live.
The dsync web interface showing a running migration with source, destination and status.
Web UI — the same run, for people who are not in a terminal.
The dsync data integrity check comparing record counts and contents between source and destination.
Integrity check — evidence the two sides agree, before you cut over.

Proof

“The Adiom components, particularly dsync, worked extremely well for us and gave us all the peace of mind to confidently proceed with the cutover.”
VP Product and Data PlatformCatalina Marketing

MongoDB to DocumentDB migration questions

What is Azure DocumentDB, and how is it related to Cosmos DB?

Azure DocumentDB is an open-source, MongoDB-compatible database built on PostgreSQL, now a Linux Foundation project. Microsoft's managed offering of it is what used to be called Azure Cosmos DB for MongoDB vCore, and the open-source build can be self-hosted. It is a different engine from Cosmos DB for MongoDB RU, the older request-unit-based service, and the two have different compatibility profiles.

Does the MongoDB replica set stay online during the migration?

Yes. The initial copy reads from MongoDB in parallel while the oplog carries every write made during it, and the application keeps using MongoDB until you cut over. Nothing has to be frozen.

How do we know our application will work on DocumentDB before we commit?

Replicate into DocumentDB continuously and run your real workload against it while MongoDB stays the system of record. Any unsupported operator, index type or behavioral difference shows up against production data and traffic instead of in a test suite. The migration only proceeds to cutover once that passes.

Are indexes migrated?

No. Dsync moves the data, not the index definitions, so indexes can be created on DocumentDB before, during or after the copy, by hand or with a script run against the source's index list. That is worth doing deliberately anyway: not every MongoDB index type has an identical DocumentDB equivalent, and DocumentDB's PostgreSQL-based storage can favor different choices, so review the index set as part of the validation run.

Can we migrate from DocumentDB back to MongoDB, or between DocumentDB deployments?

Yes. DocumentDB is supported as a source as well as a destination, in both its managed and self-hosted forms, so the same tool runs in reverse for a back-out and moves data between DocumentDB deployments.

Does this also cover Amazon DocumentDB?

This page is about Azure DocumentDB, the open-source MongoDB-compatible project. Amazon DocumentDB is a different, AWS-proprietary service, but Dsync supports it too as a source and a destination through its MongoDB connector, so a migration in either direction runs the same way.

More on DocumentDB

Free migration assessment

Tell us your MongoDB deployment and target, and we will map the path.

We reply within one business day. Your details are handled per our privacy policy.