Tools and Automation: mongodump, mongorestore, mongosh, Ops Manager/Cloud Manager
What this domain covers
Tools and Automation: mongodump, mongorestore, mongosh, and Ops Manager or Cloud Manager tests command-line tooling and automation platforms.
Core rules
- mongosh is the modern shell with a Node.js REPL. It replaces the legacy mongo shell and supports .mongoshrc.js startup scripts.
- mongodump flags include --uri, --gzip, --archive, --oplog, and --nsInclude. mongorestore flags include --drop, --oplogReplay, --nsFrom, --nsTo, --gzip, and --archive.
- mongoexport and mongoimport handle JSON or CSV for data exchange, not backups; they lose BSON type fidelity and indexes.
- Ops Manager and Cloud Manager automate deployment, monitoring, and backup. Agents run automation, monitoring, and backup; the automation config describes the desired topology.
- Use automation for repeatable deployments; use mongosh for ad hoc checks and scripted administration.
Worked example
Move the app database to a new cluster and rename it to newapp. Run mongodump with the old URI, --archive=app.archive, --gzip, and --nsInclude=app.. Restore with mongorestore using the new URI, the same archive, --gzip, and --nsFrom=app. --nsTo=newapp.*. The archive is portable and avoids thousands of files. Do not use mongoexport: it would lose types such as ObjectId and Date and would not recreate indexes.
Traps
Using mongoexport for backups; mongodump without --oplog when you need consistency; --drop on production without verification; and assuming Ops Manager backup works without the backup agent and oplog.