This version of the documentation is archived and no longer supported. To learn how to upgrade your version of MongoDB Ops Manager, refer to the upgrade documentation.
You were redirected from a different version of the documentation. Click here to go back.

Seed a New Secondary from Backup Restore


When a natural synchronization of a new secondary host costs too much time or resources, seeding a secondary from an Ops Manager Backup restore is a faster better alternative. Seeding also does not impact an active MongoDB instance to retrieve data.


To seed a secondary from a backup restore file, you must have:

  • A backup restore file.
  • The script included in the backup restore file.

When you run the script as part of this tutorial, you must provide the replica set’s oplog size, in gigabytes. If you do not have the size, see the section titled “Check the Size of the Oplog” on the Troubleshoot Replica Sets page of the MongoDB manual.


An Ops Manager backup stores all database files in a single directory. If you run MongoDB with the directoryPerDb option, then after restore you must redistribute the files to the different databases. Ops Manager Backup does not provide restoration artifacts that use the directoryPerDb option.

The file will not be in the backup restore if you have blacklisted dbs or collections or have resynced your backup after the snapshot (or for config servers). In these cases, including the script would cause an inconsistent secondary. In the case of a blacklist, your secondary would not include some collections which would cause problems for your deployment.

Seeding a new secondary from a backup restore requires an oplog window on the current primary that spans back to the snapshot’s timestamp.



Remove the broken secondary from your replica set.


Login to the server on which to create the new secondary.


Bring up new node as a standalone.

tar -xvf backup-restore-name.tar.gz
mv backup-restore-name data
mongod --port <alternate-port> --dbpath /data

Where ALTERNATEPORT is not the usual port your secondary runs on.


Run script to create oplog collection and seed with correct timestamp.

The script re-creates the oplog collection and seeds it with correct timestamp.

To run the script, issue the following command at the system prompt, where <mongod-port> is the port of the mongod instance and <oplog-size-in-gigabytes> is the size of the replica set’s oplog:

./ <mongod-port> <oplog-size-in-gigabytes>

Shut down the new secondary on the alternate port.


Start up the new secondary.

mongod --port <secondary-port> --dbpath /data  --replSet REPLICASETNAME

Add the new secondary to the replica set on the primary host.