mongodump and mongorestore — MongoDB Technical Interview Questions & Answers

Binary backup and restore utilities.

mongodump and mongorestore

  • Simple meaning: mongodump is a binary backup. mongorestore applies it. Best for “copy this database”.
  • How to use: mongodump --uri="mongodb://localhost:27017" --db=college --out=./backup
  • Restore: mongorestore --uri=... --db=college ./backup/college
  • Common mistake: restoring over production without --drop awareness. Practice on a copy.
  • Interview tip: Point-in-time-ish snapshot of BSON. Use for disaster recovery drills.

Technical Interview Tip: dump out, restore in. Same URI style as Compass.

Code Examples for mongodump and mongorestore

mongodump and mongorestore — working example

// Shell / terminal (not inside a filter query):
// mongodump --uri="mongodb://localhost:27017" --db=prep_pilot --out=./backup
// mongorestore --uri="mongodb://localhost:27017" --db=prep_pilot ./backup/prep_pilot

// Related query check after restore:
db.users.countDocuments({})
db.users.find().limit(2)

mongodump and mongorestore — mongodump/mongorestore do binary backups; verify with count/find after restore.

How to Explain mongodump and mongorestore to an Interviewer

Which tool for a full DB backup?

mongodump / mongorestore