• Restart the mongod with an empty data directory and let MongoDB’s normal initial syncing feature restore the data. This is the more simple option but may take longer to replace the data. 

See Procedures (page 634). 

• Restart the machine with a copy of a recent data directory from another member in the replica set. This procedure can replace the data more quickly but requires more manual steps. 

See Sync by Copying Data Files from Another Member (page 634). 

## Procedures 

Automatically Sync a Member Warning: During initial sync, mongod will remove the content of the dbPath . 

This procedure relies on MongoDB’s regular process for initial sync (page 594). This will store the current data on the member. For an overview of MongoDB initial sync process, see the Replication Processes (page 593) section. 

If the instance has no data, you can simply follow the Add Members to a Replica Set (page 616) or Replace a Replica Set Member (page 620) procedure to add a new member to a replica set. 

You can also force a mongod that is already a member of the set to to perform an initial sync by restarting the instance without the content of the dbPath as follows: 

1. Stop the member’s mongod instance. To ensure a clean shutdown, use the db.shutdownServer() method from the mongo shell or on Linux systems, the mongod --shutdown option. 

2. Delete all data and sub-directories from the member’s data directory. By removing the data dbPath , MongoDB will perform a complete resync. Consider making a backup first. 

At this point, the mongod will perform an initial sync. The length of the initial sync process depends on the size of the database and network connection between members of the replica set. 

Initial sync operations can impact the other members of the set and create additional traffic to the primary and can only occur if another member of the set is accessible and up to date. 

Sync by Copying Data Files from Another Member This approach “seeds” a new or stale member using the data files from an existing member of the replica set. The data files must be sufficiently recent to allow the new member to catch up with the oplog . Otherwise the member would need to perform an initial sync. 

Copy the Data Files You can capture the data files as either a snapshot or a direct copy. However, in most cases you cannot copy data files from a running mongod instance to another because the data files will change during the file copy operation. 

Important: If copying data files, you must copy the content of the local database. 

You cannot use a mongodump backup for the data files, only a snapshot backup . For approaches to capturing a consistent snapshot of a running mongod instance, see the MongoDB Backup Methods (page 184) documentation. 

Sync the Member After you have copied the data files from the “seed” source, start the mongod instance and allow it to apply all operations from the oplog until it reflects the current state of the replica set. 

