MongoDB Documentation, Release 3.0.4 Important: This procedure is only supported with the MMAPv1 storage engine. In the following procedure, you must issue the db.fsyncLock() and db.fsyncUnlock() operations on the same connection. The client that issues db.fsyncLock() is solely responsible for issuing a db.fsyncUnlock() operation and must be able to handle potential error conditions so that it can perform the db.fsyncUnlock() before terminating the connection. Step 1: Flush writes to disk and lock the database to prevent further writes. To flush writes to disk and to “lock” the database, issue the db.fsyncLock() method in the mongo shell: db.fsyncLock(); Step 3: After the snapshot completes, unlock the database. To unlock the database after the snapshot has com- pleted, use the following command in the mongo shell: db.fsyncUnlock(); Changed in version 2.2: When used in combination with fsync or db.fsyncLock() , mongod will block reads, including those from mongodump , when queued write operation waits behind the fsync lock. Do not use mongodump with db.fsyncLock() . Restore a Replica Set from MongoDB Backups Restore Database into a Single Node Replica Set This procedure outlines the process for taking MongoDB data and restoring that data into a new replica set . Use this approach for seeding test deployments from production backups as well as part of disaster recovery. You cannot restore a single data set to three new mongod instances and then create a replica set. In this situation MongoDB will force the secondaries to perform an initial sync. The procedures in this document describe the correct and efficient ways to deploy a replica set. Step 1: Obtain backup MongoDB Database files. The backup files may come from a file system snapshot (page 243). The MongoDB Cloud Manager 94 produces MongoDB database files for stored snapshots 95 and point in time snapshots$^{96}$. For an Ops Manager, an on-premise solution available in MongoDB Enterprise Advanced$^{97}$, see also documentation on Backup$^{98}$. You can also use mongorestore to restore database files using data created with mongodump . See Back Up and Restore with MongoDB Tools (page 249) for more information. Step 2: Start a mongod using data files from the backup as the data path. The following example uses /data/db as the data path, as specified in the dbpath setting: mongod --dbpath /data/db Step 2: Perform the backup operation described in Create a Snapshot . $^{94}$https://cloud.mongodb.com/?jmp=docs $^{95}$https://docs.cloud.mongodb.com/tutorial/restore-from-snapshot/ $^{96}$https://docs.cloud.mongodb.com/tutorial/restore-from-point-in-time-snapshot/ $^{97}$https://www.mongodb.com/products/mongodb-enterprise-advanced?jmp=docs $^{98}$https://docs.opsmanager.mongodb.com/core/backup-overview 247 5.2. Administration Tutorials