Restoring MongoDB Data Using Delayed Replica Set Member: Best Practices?

Hello everyone,

I’m Emmanuel Katto, working with a MongoDB replica set, and one of the members is configured as a delayed replica with a 24-hour delay (slaveDelay=86400). I need to restore the database to a specific point in time, anywhere within the past 24 hours, but I’m not sure how to achieve this effectively.

I know mongorestore has an option called --oplogLimit=<timestamp>, which is useful for restoring to a point in time, but I’m having trouble figuring out how to dump the delayed member’s data and the entire oplog. The issue is that I want the oplog to include all changes made to the delayed member up until the current moment, not just the changes applied during the mongodump operation.

When I run mongodump with the --oplog flag, I get the oplog from the member I dump from, which includes changes during the dump itself, but I’m not sure how to dump the full oplog from the replica set that includes entries up to the current time.

The closest solution I found was this one: [Modify and replay MongoDB oplog - Stack Overflow 5], but I feel like there should be a simpler approach to this.

Has anyone encountered this situation? Any suggestions or best practices for restoring a MongoDB replica set using a delayed member and including all the oplog entries?

Looking forward to hearing your thoughts!

Emmanuel Katto