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.
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.
rs.status()Replica sets are the basis for redundancy and high availability in production MongoDB deployments.
rs.initiate()This is commonly used during local testing or first-time replica set setup.
mongostat --uri="mongodb://localhost:27017"`mongostat` provides a quick operational overview of a running deployment.
mongotop --uri="mongodb://localhost:27017"Useful for identifying where activity is concentrated across collections.