I have a MongoDB database that has grown to several terabytes in size. My primary concern is to back up only the users and roles, without the rest of the data. Given the large size of the database, what is the most efficient way to achieve this?
I’ve researched a bit and understand that MongoDB’s mongodump can export specific collections, but I am unsure how to use it specifically for users and roles. Additionally, if there are any other methods or best practices for this scenario, I would greatly appreciate the guidance.
Thank you in advance!
I attempted to use the mongodump and mongorestore commands with various options to target the admin database, expecting it to back up and restore only the user and role information. Here are the commands I used:
mongodump -u msaf -d admin –dumpDbUsersAndRoles –out=/backup/ –authenticationDatabase admin
mongorestore -u msaf –authenticationDatabase admin –db admin –dir=/backup/admin/system.users.bson –excludeCollection system.version