Restoring a MongoDB dump means running mongorestore (or, for newer setups, the MongoDB Database Tools that include it) against a target mongod or mongos instance and pointing it at either a BSON dump directory or an archive file, typically produced earlier by mongodump. The key condition is that the dump's BSON and metadata must match or be compatible with the target server version, storage engine, and collection options, or the restore will fail partway. This guide walks through the ordered actions, the success checks at each stage, and the failure modes that most often stop a restore cold. It assumes you already have a dump file or directory and shell access to the machine that will run the restore. The reference date is late 2026, so tool naming follows the post-mongodump-split packaging described below.
What "the MongoDB dump" actually contains, and why the shape matters
Before touching a command, know what you're holding. A conventional mongodump output is a directory tree: one subdirectory per restored database, and inside it one .bson file per collection plus a .metadata.json file per collection that records indexes, options, and the collection type. A mongodump --archive run instead produces a single file (or a stream to stdout) that bundles the same content, optionally compressed. The BSON files hold the documents; the metadata files hold everything else needed to rebuild the collection faithfully.
That distinction drives which restore flag you use. If you have a directory, you point mongorestore at it directly. If you have an archive, you restore with --archive=path and, if it was compressed during dump, --gzip. Getting this wrong produces the classic "don't know what to do with subdirectory" or "no such file" errors before any data is written.
One more shape to recognize: a dump taken with --oplog includes an oplog.bson file at the top level, which lets you restore a point-in-time consistent snapshot or replay operations up to a moment. A dump without it is a plain snapshot. Neither is "better" universally; the oplog version is what you want if you're recovering from a replica set and need a consistent cutoff.
Prerequisites: tools, versions, and permissions
The single biggest cause of a failed restore is a tool-versus-server mismatch, so handle this first.
The MongoDB Database Tools package was split out from the server long ago; by the 2020s and into 2026, mongorestore ships in the standalone Database Tools distribution rather than inside the server tarball. Confirm you actually have it with mongorestore --version. If the command isn't found, install the Database Tools for your platform before proceeding; don't try to use an old bundled binary from a server package.
Match the tools to the server. In general, use Database Tools whose major version is equal to or newer than the target mongod, but not older. Running an old tool against a newer server is where metadata parsing and option validation break. If you're restoring into MongoDB 7.0 or 8.0-era servers, use a current Database Tools release rather than one left over from a 4.x deployment.
You also need credentials and a target. Decide whether you're restoring into a fresh empty instance, an existing database (where you must decide whether to drop existing collections first), or a different database name via --nsFrom/--nsTo remapping. And confirm the target user has the restore role or equivalent privileges on the destination databases.
A quick pre-flight check: can you connect and run a trivial command? mongosh --host --port --eval "db.runCommand({ping:1})" returning ok: 1 confirms network, auth, and server health before you invest in a restore run.
Step 1: Inspect the dump before you restore
You have two goals here: identify the format and estimate the scope.
For a directory dump, list the top level. You should see database directories, and possibly a admin directory and an oplog.bson. List inside one database directory to confirm paired .bson and .metadata.json files. If you see only .bson files with no metadata, the dump was taken with --noIndexRestore or an old tool; indexes will need rebuilding separately, which matters for performance and uniqueness constraints.
For an archive, you can't just list it with ls, but you can inspect the manifest using mongorestore --archive=path --dryRun (a validation pass that parses but doesn't write) before committing. A dry run is one of the most underused safeguards: it surfaces format and option errors while nothing is on the line.
Note the total size. On the target, check free disk space: restored BSON plus indexes plus any oplog replay typically needs more than the raw dump size, because indexes are rebuilt and the WiredTiger storage engine keeps working space. Rule of thumb: provision at least 1.5–2× the uncompressed BSON size, more if you're replaying an oplog or if the target will hold both old and new copies.
Success check for this step: you know the format (directory vs. archive, compressed or not), the databases and collections present, whether metadata exists, and you have a disk-space number that comfortably exceeds the dump's uncompressed footprint.
Step 2: Choose the right restore mode
The mongorestore behavior you want depends on your situation, and the flags are not interchangeable.
A plain restore into an empty database is the simplest: point at the dump and let it insert. If the target already has data, you have options. --drop removes each collection in the target before restoring it, which gives you a clean snapshot but deletes anything created after the dump. Without --drop, mongorestore inserts documents and will throw duplicate-key errors on _id collisions, stopping or skipping depending on --stopOnError and --bypassDocumentValidation. Choose --drop when you intend a full replacement; choose insert-only when merging into a database that should retain extra collections.
For restoring into a differently named database, use namespace remapping: --nsFrom='olddb.' --nsTo='newdb.'. This is the safe path for "restore production dump into a staging server" without renaming the dump itself.
If your dump has an oplog.bson, you can replay it with --oplogReplay (with optional --oplogLimit to stop at a timestamp), which reproduces the state as of the dump plus subsequent operations. Without an oplog file, that flag does nothing useful.
One more mode: --gzip must match how the dump was taken. An archive compressed at dump time needs --gzip at restore time; a directory dump that was tarred and gzipped needs to be extracted first. Mixing these is a frequent source of "unexpected end of file" errors.
A caution on destructive flags: --drop and --oplogReplay are the two that can remove or alter live data fastest. Run a dry run first, and if the target matters, take a backup of it before proceeding.
Step 3: Run the restore command
Now the executable step. The canonical directory restore into a local server looks like this:
mongorestore --host localhost --port 27017 --username --password --authenticationDatabase admin --drop /path/to/dump
For an archive with compression:
mongorestore --host --archive=/path/to/dump.archive --gzip --drop
For a namespaced remap:
mongorestore --host --nsFrom='prod.' --nsTo='staging.' /path/to/dump
For oplog replay:
mongorestore --host --oplogReplay --oplogLimit='1700000000:1' /path/to/dump
Run with --dryRun first if the target is anything but a throwaway instance. The dry run parses the dump and validates options without writing; if it completes cleanly, you've eliminated the format and permission class of errors. Add --verbose when you want per-collection progress, and --numInsertionWorkersPerCollection (default 1) to parallelize inserts on large collections, which speeds restores considerably at the cost of more concurrent load on the target.
Expect progress output listing each collection, the number of documents restored, and the number of index entries. If it stops on a duplicate key, you chose insert-only against a populated target; if it stops on a metadata error, you have a version or option mismatch; if it hangs on a single collection, check for a large index build or a lock.
Success check: the command exits with status 0, the summary reports numerators restored, and no collection is reported as failed. A nonzero exit status always warrants reading the last lines before assuming partial success.
Step 4: Verify the restore actually worked
Exit code 0 is necessary but not sufficient. Verify at three levels.
Count level: for each database and collection, compare document counts in the source dump expectation against the target. You can derive the expected count from the dump's metadata or from a recorded source count; on the target, db..countDocuments() gives the restored figure. Counts can legitimately differ if the dump was filtered or if --oplogReplay extended the snapshot, so reconcile against the right baseline.
Index level: confirm indexes exist, since a metadata-less dump restores documents but not indexes. Query db..getIndexes() and check for the expected id index, unique constraints, and query-supporting indexes. Missing indexes won't fail the restore but will cause slow queries and can break uniqueness guarantees, so this is a real correctness check, not a nicety.
Spot-check level: read a handful of documents you can identify and confirm fields, types, and nested structure survived. BSON round-trips types cleanly (dates stay dates, ObjectIds stay ObjectIds), so if you see dates as strings, the dump was exported through a different tool—worth investigating before trusting the whole dataset.
A faster structural check for large datasets: compare db.stats() object counts per collection, and if the dump preserved an oplog, confirm the collection count matches the number of distinct namespaces in the oplog.
Common failure modes and how to read them
"Failed: connection refused" or auth errors. The target isn't reachable or credentials are wrong. Confirm host/port, that authentication is enabled, and that --authenticationDatabase points to the database where the user was created (often admin).
"restore: error while parsing metadata: unknown option." Tool and server versions disagree. Upgrade the Database Tools to match or exceed the server major version.
"E11000 duplicate key error." You restored into a populated target without --drop. Decide whether to drop and re-restore, or to skip existing documents with --bypassDocumentValidation? No—bypassing validation doesn't skip duplicates. Use namespace remapping to a clean database or handle duplicates explicitly; there's no global "ignore duplicates" switch, so check what --stopOnError is doing.
"storage engine mismatch" or "WiredTiger error." Dump taken with a different storage engine than the target. MongoDB removed the MMAPv1 engine, so dumps from very old deployments may not be restorable into modern servers; verify engine compatibility and, if needed, migrate data through the application layer.
Restore crawls to a halt on one collection. Likely an index build, a huge collection, or a lock. Adding insertion workers may help on a capable target; otherwise let the index build finish rather than killing it, since a killed build leaves the restore incomplete.
Disk full mid-restore. You underestimated the target footprint. Free space or expand storage, then restart; partial collections from a killed run should be dropped before retrying to avoid duplicate-key noise.
Stop condition: if the metadata parse fails in a way you cannot resolve by matching tool versions, or if you see storage-engine corruption errors in the target logs, stop and bring in someone familiar with the MongoDB deployment rather than repeatedly retrying. The same goes for any restore into a production cluster that requires oplog replay or replication reconfiguration—those are recovery operations with real consequences, not routine file copies.
When it's not a plain mongorestore: archives, replica sets, and point-in-time
Three situations diverge from the simple path and deserve their own logic.
An archive that you only have as a stream still restores: pipe it into mongorestore --archive reading from stdin. This is how "give me the dump" often arrives in cloud tooling—a single file rather than a directory tree. Uncompressing a .tar.gz directory dump first is always safe but costs disk; keeping it as an archive and using --archive --gzip avoids the extraction.
For a replica set or sharded cluster, restore the primary and let secondaries replicate—if you restore in place, restore each node, but the normal path is to restore one node and let the cluster's own replication carry it. Oplog replay against a replica set gives you a consistent cutoff for recovery from a single known-good dump; use --oplogLimit to stop at a specific timestamp. If you're combining dump plus oplog for point-in-time recovery, the dump must have been taken with --oplog so the matching oplog exists; you can't fabricate it after the fact.
For a fresh cluster with a clean slate, you can also define recovery targets in terms of target versions: a 7.0 dump restored into 8.0-era servers should work if tools match, but a dump from an ancient 4.x deployment, especially one on the removed MMAPv1 engine, needs a migration path rather than a direct restore. When in doubt, restore into a throwaway instance of the same major version as the source first, verify, then migrate forward.
Sanity-check arithmetic for planning the restore
A worked estimate keeps you out of surprises. Suppose a directory dump reports 400 GB of BSON across collections, and you'll rebuild indexes that add, say, 25% of the data size, and WiredTiger working space needs headroom. Multiply 400 GB by 1.5 to get 600 GB as a conservative target-only estimate, then add headroom for the oplog if replaying. If you plan to also keep the current target data alongside (no --drop), double again. These are illustrative multipliers, not guarantees—actual overhead depends on collection sizes, index definitions, compression, and how many existing collections you retain—but the method isolates the three contributors (data, indexes, retained old data) so you can size each.
Time is a separate axis. Restore throughput depends on target I/O, index builds, and insertion workers, so instead of guessing a wall-clock number, do a dry run plus a small measured sample—restore a subset or one small database and measure—then extrapolate with the understanding that large index builds don't scale linearly. That's more reliable than any generic throughput figure applied blindly.
Bringing it back safely
The restore is the easy half; making it trustworthy is the other. Before you call it done: counts and indexes match expectations, a spot-check of documents looks right, the application can connect and query, and any index rebuild you deferred is scheduled and completed. Record what you restored, from which dump, with which tool version and flags, so the next person isn't reverse-engineering the command from shell history.
If this is a recovery into a production system, the last check is whether replication, authentication, and backup schedules are intact—a restore can overwrite documents, but it doesn't recreate users, roles, or backup jobs. Those live outside the dump and must be verified separately. On the question of recovering a dump, the routine ends with a verified, queryable database and a written record of the exact restore that produced it; anything short of that is an unverified copy, not a recovery.