0

mongodb replica set is PSS:

d1node - SECONDARY

d2node - PRIMARY

d3node - RECOVERING

mongo ... --host=d3node --port =1234

mongo1234:RECOVERING> rs.printSlaveReplicationInfo()
source: d1node:1234
        syncedTo: Fri Mar 18 2022 16:37:48 GMT+0000 (UTC)
        0 secs (0 hrs) behind the primary
source: d3node:1234
        syncedTo: Fri Mar 18 2022 16:37:48 GMT+0000 (UTC)
        3600 secs (1 hrs) behind the primary
mongo1234:RECOVERING>

d3node is 1 hour behind primary. How to query mongo to get only 3600 seconds into a variable called N_SECONDS.

I'm assuming that secondary is 1 hour behind MASTER_OPTIME where,

MASTER_OPTIME=$(eval mongo ... 'rs.status().members.filter( x => x.stateStr == "PRIMARY" ).shift().optime.ts')

how to get this value to run mongodump oplog backup.

OPLOG_START= MASTER_OPTIME - N_SECONDS

mongodump ... --query '{"ts": { "$gt": "Timestamp($OPLOG_START, 1)" } }'

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.