0PricingLogin
MongoDB Academy · Lesson

mongodump and mongorestore for Full Backups

Learners will create a full BSON dump of a database and restore it to a different cluster with mongorestore.

Why Use mongodump for Backups?

mongodump creates a binary BSON snapshot of a database or collection. Unlike mongoexport, which produces human-readable JSON, mongodump preserves all BSON type information exactly—ObjectIds, dates, decimals, binary data—with zero loss of fidelity. This makes it the correct tool for full database backups and migrations between MongoDB clusters, while mongoexport is better for selective data sharing.

Basic mongodump Usage

Running mongodump without arguments dumps all databases from the local MongoDB instance to a dump/ directory. Specify --uri, --db, and optionally --collection to narrow the scope. The output directory contains one subdirectory per database, each with .bson and .metadata.json files per collection.

# Dump the entire 'myapp' database
mongodump \
  --uri 'mongodb://localhost:27017' \
  --db myapp \
  --out /backups/myapp-2024-01-15

# Output structure:
# /backups/myapp-2024-01-15/
#   myapp/
#     users.bson
#     users.metadata.json
#     products.bson
#     products.metadata.json

All lessons in this course

  1. mongoimport: Loading JSON and CSV Files
  2. mongoexport: Dumping Collections to Files
  3. mongodump and mongorestore for Full Backups
  4. Seeding Data With Node.js Scripts
← Back to MongoDB Academy