- Back Up MongoDB Deployments >
- Restore MongoDB Instances with Backup >
- Seed a New Secondary from Backup Restore
Seed a New Secondary from Backup Restore¶
On this page
Overview¶
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.
Prerequisites¶
To seed a secondary from a backup restore file, you must have:
- A backup restore file.
- The
seedSecondary.sh
script included in the backup restore file.
When you run the seedSecondary.sh
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.
Considerations¶
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 seedSecondary.sh 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.
Procedure¶
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.¶
Where ALTERNATEPORT
is not the usual port your secondary runs on.
Run seedSecondary.sh script to create oplog collection and seed with correct timestamp.¶
The seedSecondary.sh 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: