Mongorestore using OplogReplay

Hi Team,

I have dropped a collection from my TestDB (from both Stage and Prod Server), and I wanted to restore it back using OplogReplay by taking backup of oplog.rs collection. But it is throwing the below error.
Can you please help?

Note: I am using AKS cluster.

Syntax:
mongorestore --host=xxxxxxxx --port 27017 --oplogReplay --oplogLimit 1644392307 --authenticationDatabase admin -u xxxxxx -p xxxx /var/lib/mongodb/local/oplog.rs.bson

Stage Server Error:

Failed: restore error: error applying oplog: applyOps: (Unauthorized) not authorized on admin to execute command { applyOps: [ { ts: Timestamp(1641288700, 2), t: 1, h: null, v: 2, op: “c”, ns: “config.$cmd”, o: { create: “system.indexBuilds”, idIndex: { v: 2, key: { _id: 1 }, name: “id” } } } ], lsid: { id: UUID(“a3a053a6-ef03-44e9-ad18-69d44040f577”) }, $clusterTime: { clusterTime: Timestamp(1644407312, 1), signature: { hash: BinData(0, 5219E1B914EF211962681D46B336D3864642C59F), keyId: 7049281289794355202 } }, $db: “admin”, $readPreference: { mode: “primaryPreferred” } }
2022-02-09T11:48:32.786+0000 0 document(s) restored successfully. 0 document(s) failed to restore.

Production Server Error:

Now we are getting error in Stage server, I am not sure why Duplicate Key error is coming for a table which is dropped.

2022-02-09T12:22:03.295+0000 skipping applying the config.system.sessions namespace in applyOps
2022-02-09T12:22:03.296+0000 skipping applying the config.system.sessions namespace in applyOps
2022-02-09T12:22:03.296+0000 skipping applying the config.transactions namespace in applyOps
2022-02-09T12:22:03.398+0000 oplog 694MB
2022-02-09T12:22:03.403+0000 Failed: restore error: error handling transaction oplog entry: error applying transaction op: applyOps: (DuplicateKey) E11000 duplicate key error collection: DataUniverseStg.Hierarchy index: HierachyIDandDUPKI dup key: { HierarchyID: 1343, DU_PKI: 15 }
2022-02-09T12:22:03.403+0000 0 document(s) restored successfully. 0 document(s) failed to restore.

Hi Team,

Any suggestion?

Thanks,
Rana

Check this jira ticket.It suggests to use additional parameter
https://jira.mongodb.org/browse/TOOLS-2041