-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.0.3
-
Component/s: mongorestore
-
None
I am using the following command to restore the data from an oplog file
mongorestore --host localhost --port 28025 -u user -p password --authenticationDatabase admin --oplogFile 0000000000_0_oplog.bson --oplogReplay --oplogLimit=1553063755
User Details:
{
"_id" : "admin.user",
"user" : "user",
"db" : "admin",
"roles" : [
],
"mechanisms" : [
"SCRAM-SHA-1",
"SCRAM-SHA-256"
]
}
I am getting an error when restoring the following document from oplog collection.
{ "ts": { "$timestamp": { "t": 1552888562, "i": 3 } }, "t": { "$numberLong": "1" }, "h": { "$numberLong": "-8964353497436574374" }, "v": 2, "op": "c", "ns": "admin.$cmd", "ui": { "$binary": "pNTQsAJRRkC+MJUMMFm9hg==", "$type": "04" }, "wall": { "$date": "2019-03-18T05:56:02.889Z" }, "o": { "create": "system.keys", "idIndex": { "v": 2, "key": { "_id": 1 }, "name": "_id_", "ns": "admin.system.keys" } } }
Error:
Failed: restore error: error applying oplog: applyOps: not authorized on admin to execute command { applyOps: [ { ts: Timestamp(1552888562, 3), h: -8964353497436574374, v: 2, op: "c", ns: "admin.$cmd", o: { create: "system.keys", idIndex: { v: 2, key:
{ _id: 1 }, name: "id", ns: "admin.system.keys" } }, o2: {} } ], $db: "admin" }
But this works when I am running the mongod instance without any authentication and restore using the following command.
mongorestore --host localhost --oplogFile 0000000000_0_oplog.bson --oplogReplay --oplogLimit=1553063755