mongodump --uri="mongodb://localhost:27017/appdb" --out=./dump`mongodump` creates a logical BSON dump that can later be restored with `mongorestore`.
Use mongodump, mongorestore, replica set commands, and diagnostic tools for operational MongoDB workflows.
Logical backup workflows with the MongoDB Database Tools.
mongodump --uri="mongodb://localhost:27017/appdb" --out=./dump`mongodump` creates a logical BSON dump that can later be restored with `mongorestore`.
mongodump --uri="mongodb://localhost:27017/appdb" --collection=users --out=./dumpUseful for targeted migrations or testing.
Restore into a collection or database after clearing prior content.
mongorestore --uri="mongodb://localhost:27017/appdb" --drop ./dump`--drop` removes existing collections before restoring them.
Restore a subset of data from a larger dump.
mongorestore --uri="mongodb://localhost:27017" --nsInclude="appdb.users" ./dumpSelective restore is useful in incident recovery and environment seeding.
mongodump --uri="mongodb://localhost:27017/appdb" --archive | gzip > appdb.archive.gzA convenient way to produce one compressed artifact for transport or storage.
Core commands for replica set awareness and quick operational checks.
Inspect members, state, and health.
rs.status()Replica sets are the basis for redundancy and high availability in production MongoDB deployments.
Initialize a replica set on a self-managed deployment.
rs.initiate()This is commonly used during local testing or first-time replica set setup.
See high-level runtime activity.
mongostat --uri="mongodb://localhost:27017"`mongostat` provides a quick operational overview of a running deployment.
See how much time collections spend reading and writing.
mongotop --uri="mongodb://localhost:27017"Useful for identifying where activity is concentrated across collections.