Data Migration and Data Movement
This domain tests choosing a migration method, preserving data fidelity, and cutting over with minimal downtime.
Core rules
- mongodump and mongorestore move BSON and indexes and suit offline or smaller migrations. Use --oplog with mongodump and --oplogReplay with mongorestore for a more consistent point-in-time copy.
- mongoexport and mongoimport handle JSON or CSV but do not preserve indexes, and can lose type fidelity for dates, ObjectIds, and numbers. They are not full migration tools.
- mongomirror continuously replicates a replica set source to Atlas and underpins the Atlas Live Migration service. The source must be reachable and the oplog retained long enough to catch up.
- mongosync provides cluster-to-cluster sync for replica sets and sharded clusters, with filtering and a controlled cutover API.
- Pre-migration checks include MongoDB version compatibility, index build time, collation, users and roles, driver compatibility, and DNS TTL.
Worked example
A 500 GB replica set on MongoDB 4.4 must move to Atlas 7.0 with under 30 minutes of downtime. Use Atlas Live Migration or mongomirror, not mongoexport. Pre-create required users, verify the source oplog window, start continuous sync, and monitor lag. At cutover, stop application writes, wait for lag to reach zero, compare document counts and indexes, switch the connection string, and keep the source read-only for rollback.
Traps
Using mongoexport for a production migration; forgetting that indexes are not copied by mongoexport; underestimating index build time; cutting over with replication lag; lowering DNS TTL too late; having no rollback path.