'Mongorestore for oplog.rs collection is not working - restore error: applyOps: (DuplicateKey) E11000 duplicate key error collection

I am trying to enable mongodb backup on Azure Kubernetes Services(AKS). I have taken mongodump of oplog.rs collections. Now i want to take only one dropped collection from oplog.rs. I have found out the timestamp of the dropped collection. When i am trying to restore giving me below error.

Mongodump command which i used :

nohup mongodump --host=hostname --db=local --collection=Oplog.rs --username=username --authenticationDatabase=admin --password=password --out="/var/backup/" 

Mongorestore command :

mongorestore --host=hostname --port=27017 --username="username" --password="password" --authenticationDatabase=admin --oplogReplay --oplogLimit 1643871153 /var/backup/local/oplog.rs.bson

Its showing following error :

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.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source