Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb backup role - mongodump

We have a development team that will periodically take a mongodump out of DEV and then restore it back to their local host for work. We have recently implemented authentication in mongodb and i would like to be able to allow our development team do a mongodump on one DB only so they can restore it to their local host.

I have a role that inherits the backup role from Admin, but that is for our DBA to backup the whole system.

My question, how do I allow for this backup role to be used by a specific user (lets call them "webdev") for a specific DB (lets call it "products")?

like image 822
Govna Avatar asked Oct 29 '25 19:10

Govna


1 Answers

You can create an user in the products database with read permissions:

> use products
> db.createUser(  {
 user: "webdev",
 pwd: "password",
 roles: [ "read" ]
 } )

Just remember to call mongodump with --excludeCollectionsWithPrefix=system

mongodump --excludeCollectionsWithPrefix=system

In order to avoid permission errors (assuming you are using Mongo 3)

like image 109
andresk Avatar answered Oct 31 '25 11:10

andresk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!