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

mongorestore not restoring roles from non-admin databases

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8.0-rc3
    • Affects Version/s: 2.8.0-rc2
    • Component/s: mongorestore
    • None
    • Environment:
      OS X 10.10.1, Macbook Pro Retina 13

      steps to reproduce: start mongod, create custom role, create user with custom role, dump everything, start new mongod with clean dbpath, restore everything.

      this happens with both 2.6 and 2.8 mongodump

      In the restored version, there is no system.roles collection. (but there is a system.roles.bson in the dump).

          var baseName = "test";
          var dumpdir = MongoRunner.dataDir + "/" + baseName + "/";
      
          var t = new ToolTest(baseName + "_dirty", {auth: "", binVersion: "2.8", vvv:""});
      
          var coll = t.startDB("dummy");
          var adminDB = coll.getDB().getSiblingDB("admin");
          var testDB = coll.getDB().getSiblingDB("test");
      
          adminDB.createUser({
              user: "admin",
              pwd: "admin",
              roles: jsTest.adminUserRoles
          });
      
          adminDB.auth({
              user: "admin",
              pwd: "admin"
          });
      
          testDB.runCommand({
              createRole: "custom",
              privileges: [],
              roles: []
          });
      
          testDB.createUser({
              user: "user1",
              pwd: "user1",
              roles: ["custom"]
          });
      
          t.runTool(
              "dump", 
              "--username", "admin", 
              "--password", "admin", 
              "--out", dumpdir
          );
      
          t.stop();
      
          // t = new ToolTest(baseName, {binVersion: "2.8", auth:""}); //TOOLS-440
          t = new ToolTest(baseName + "_clean", {binVersion: "2.8", vvv:""}); 
      
          coll = t.startDB("dummy")
          adminDB = coll.getDB().getSiblingDB("admin");
          testDB = coll.getDB().getSiblingDB("test");
      
          t.runTool("restore", "--dir", dumpdir);
      

            Assignee:
            kyle.erf Kyle Erf
            Reporter:
            robert.guo@mongodb.com Robert Guo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: