I'm new to MongoDB and I'm testing some basic backup and restore operations in a single MongoDB instance.
All tests worked fine except for restoring users.
I first created a backup of a test database (db_test) using the following command:
$ mongodump -u adm_dump --authenticationDatabase admin -d db_test --dumpDbUsersAndRoles -o /opt/backup/mongodump_db_test
adm_dump is a user I created with "restore" and "backup" roles.
2 users are present in db_test database with "readWrite" and "read" roles respectively. So I was expecting these both users to be restored.
Then I restored the database into database db_test_2 (not existing):
$ mongorestore -u adm_dump --authenticationDatabase admin -d db_test_2 --restoreDbUsersAndRoles /opt/backup/mongodump_db_test/db_test
The new database db_test_2 is successfully created (all collections are restored) but users are not restored in db_test2.
Below the log tail:
...
2016-06-29T18:28:26.429+0200 restoring users from /opt/backup/mongodump_db_test/db_test/$admin.system.users.bson
2016-06-29T18:28:26.464+0200 roles file '/opt/backup/mongodump_db_test/db_test/$admin.system.roles.bson' is empty; skipping roles restoration
2016-06-29T18:28:26.464+0200 restoring roles from /opt/backup/mongodump_db_test/db_test/$admin.system.roles.bson
2016-06-29T18:28:26.468+0200 done
I also granted the "userAdmin" role to adm_dump and did operations several times with no success. Should I give another specific role to adm_dump user ?
I read the doc and googled on dumpDbUsersAndRoles / restoreDbUsersAndRoles options but found nothing relevant.
What did I miss to restore users from a dump backup ?
MongoDB version 3.2.1 on CentOS 6.6
user admin;
thendb.system.users.find();
, that will help show you what user accounts do exist. – Vince Bowdren