Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2238

mongorestore fails when using with authentication

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 4.0.3
    • Fix Version/s: No versions
    • Component/s: mongorestore
    • Labels:
      None

      Description

      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" : [

      { "role" : "root", "db" : "admin" }

      ],
      "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

        Attachments

          Activity

            People

            Assignee:
            seth.payne Seth Payne (Inactive)
            Reporter:
            manivannan89 Manivannan
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: