This version of the documentation is archived and no longer supported.

MongoDB Backup Methods

When deploying MongoDB in production, you should have a strategy for capturing and restoring backups in the case of data loss events. There are several ways to back up MongoDB clusters:

Backup by Copying Underlying Data Files

You can create a backup by copying MongoDB’s underlying data files.

If the volume where MongoDB stores data files supports point in time snapshots, you can use these snapshots to create backups of a MongoDB system at an exact moment in time.

File systems snapshots are an operating system volume manager feature, and are not specific to MongoDB. The mechanics of snapshots depend on the underlying storage system. For example, if you use Amazon’s EBS storage system for EC2 supports snapshots. On Linux the LVM manager can create a snapshot.

To get a correct snapshot of a running mongod process, you must have journaling enabled and the journal must reside on the same logical volume as the other MongoDB data files. Without journaling enabled, there is no guarantee that the snapshot will be consistent or valid.

To get a consistent snapshot of a sharded system, you must disable the balancer and capture a snapshot from every shard and a config server at approximately the same moment in time.

If your storage system does not support snapshots, you can copy the files directly using cp, rsync, or a similar tool. Since copying multiple files is not an atomic operation, you must stop all writes to the mongod before copying the files. Otherwise, you will copy the files in an invalid state.

Backups produced by copying the underlying data do not support point in time recovery for replica sets and are difficult to manage for larger sharded clusters. Additionally, these backups are larger because they include the indexes and duplicate underlying storage padding and fragmentation. mongodump, by contrast, creates smaller backups.

For more information, see the Backup and Restore with Filesystem Snapshots and Backup a Sharded Cluster with Filesystem Snapshots for complete instructions on using LVM to create snapshots. Also see Back up and Restore Processes for MongoDB on Amazon EC2.

Backup with mongodump

The mongodump tool reads data from a MongoDB database and creates high fidelity BSON files. The mongorestore tool can populate a MongoDB database with the data from these BSON files.

Use Cases

mongodump and mongorestore are simple and efficient for backing up small MongoDB deployments, for partial backup and restores based on a query, syncing from production to staging or development environments, or changing the storage engine of a standalone.

However, these tools can be problematic for capturing backups of larger systems, sharded clusters, or replica sets. For alternatives, see MongoDB Cloud Manager Backup or Ops Manager Backup Software.

Data Exclusion

mongodump excludes the content of the local database in its output.

mongodump only captures the documents in the database in its backup data and does not include index data. mongorestore or mongod must then rebuild the indexes after restoring data.

Data Compression Handling

When run against a mongod instance that uses the WiredTiger storage engine, mongodump outputs uncompressed data.


mongodump can adversely affect the performance of the mongod. If your data is larger than system memory, the mongodump will push the working set out of memory.

If applications modify data while mongodump is creating a backup, mongodump will compete for resources with those applications.

To mitigate the impact of mongodump on the performance of the replica set, use mongodump to capture backups from a secondary member of a replica set.

Applications can continue to modify data while mongodump captures the output. For replica sets, mongodump provides the --oplog option to include in its output oplog entries that occur during the mongodump operation. This allows the corresponding mongorestore operation to replay the captured oplog. To restore a backup created with --oplog, use mongorestore with the --oplogReplay option.

However, for replica sets, consider MongoDB Cloud Manager Backup or Ops Manager Backup Software.

See Back Up and Restore with MongoDB Tools, Backup a Small Sharded Cluster with mongodump, and Backup a Sharded Cluster with Database Dumps for more information.

MongoDB Cloud Manager Backup

The MongoDB Cloud Manager supports the backing up and restoring of MongoDB deployments.

MongoDB Cloud Manager continually backs up MongoDB replica sets and sharded clusters by reading the oplog data from your MongoDB deployment.

MongoDB Cloud Manager Backup offers point in time recovery of MongoDB replica sets and a consistent snapshot of sharded clusters.

MongoDB Cloud Manager achieves point in time recovery by storing oplog data so that it can create a restore for any moment in time in the last 24 hours for a particular replica set or sharded cluster. Sharded cluster snapshots are difficult to achieve with other MongoDB backup methods.

To restore a MongoDB deployment from an MongoDB Cloud Manager Backup snapshot, you download a compressed archive of your MongoDB data files and distribute those files before restarting the mongod processes.

To get started with MongoDB Cloud Manager Backup, sign up for MongoDB Cloud Manager. For documentation on MongoDB Cloud Manager, see the MongoDB Cloud Manager documentation.

Ops Manager Backup Software

MongoDB Subscribers can install and run the same core software that powers MongoDB Cloud Manager Backup on their own infrastructure. Ops Manager, an on-premise solution, has similar functionality to the cloud version and is available with Enterprise Advanced subscriptions.

For more information about Ops Manager, see the MongoDB Enterprise Advanced page and the Ops Manager Manual.

Further Reading

Backup and Restore with Filesystem Snapshots
An outline of procedures for creating MongoDB data set backups using system-level file snapshot tool, such as LVM or native storage appliance tools.
Restore a Replica Set from MongoDB Backups
Describes procedure for restoring a replica set from an archived backup such as a mongodump or MongoDB Cloud Manager Backup file.
Back Up and Restore with MongoDB Tools
Describes a procedure for exporting the contents of a database to either a binary dump or a textual exchange format, and for importing these files into a database.
Backup and Restore Sharded Clusters
Detailed procedures and considerations for backing up sharded clusters and single shards.
Recover a Standalone after an Unexpected Shutdown
Recover data from MongoDB data files that were not properly closed or have an invalid state.