Restore a Replica Set from MongoDB Backups¶
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.
Restore Database into a Single Node Replica Set¶
Obtain backup MongoDB Database files.¶
The backup files may come from a file system snapshot. The MongoDB Cloud Manager produces MongoDB database files for stored snapshots and point in time snapshots. For Ops Manager, an on-premise solution available in MongoDB Enterprise Advanced, see also the Ops Manager Backup overview.
Add Members to the Replica Set¶
MongoDB provides two options for restoring secondary members of a replica set:
- Manually copy the database files to each data directory.
- Allow initial sync to distribute data automatically.
The following sections outlines both approaches.
If your database is large, initial sync can take a long time to complete. For large databases, it might be preferable to copy the database files onto each host.
Use the following sequence of operations to “seed” additional members of the replica set with the restored data by copying MongoDB data files directly.
Update Secondaries using Initial Sync¶
Use the following sequence of operations to “seed” additional members of the replica set with the restored data using the default initial sync operation.