Appearance
MongoDB Backup and User Roles
MongoDB Backup and User Roles
At Simplebackups, we believe in the principle of least privilege. This principle suggests that a user should be granted the minimum levels of access necessary to complete their tasks. This approach enhances the security of our systems and the integrity of our data. In line with this, we encourage the use of MongoDB’s built-in backup role for performing backup operations. This role provides the necessary permissions to perform backups without granting unnecessary access to your MongoDB system.
- Connect to the MongoDB instance using the mongo shell or a MongoDB client.
shell
mongo --host <hostname> --port <port> -u <admin_user> -p <password> --authenticationDatabase admin- Create a user and assign the
backuprole to the user:
javascript
use admin
db.createUser({
user: "<backup_user>",
pwd: "<password>",
roles: [{ role: "backup", db: "admin" }]
})With the backup role assigned to this user, you can now use this user to back up your MongoDB using SimpleBackups. This will allow you to leverage MongoDB's built-in security roles while also keeping your MongoDB system secure.