We have a multi-tenant micro-service (it's basically kafka with some bells and whistles). We are using Mongodb to store multi-tenant credentials and kafka data so the authentication is really tight. Like, tenant1 will get to read/write tenant1-db and it's collections, it has no other access, same with tenant2 and so on.. If for some reason I want to access tenant data I will have to login using credentials for that user on that database.

My question is, how do I create a full and incremental backup script for this? My concern is since I can't read other databases even as root without authenticating will I have to write a loop for it or something where it logs in for every user then uses mongodump and stores it in a file? Is there a simpler way? I know there's a user called backup but it can only take backup of the admin / root user and not other databases Every time there's a new tenant I feel like I will have to make changes to the backup script

I am fairly new to mongodb so I would appreciate some help. Thank you!

  • 1
    Not clear what you mean "as root without authenticating" is a contradiction in itself. Either you are authenticated as root, then you have read/write privileges to all collections or you don't. Also, there is no (pre-defined) user "backup" in MongoDB. There is only a built-in role backup, but this roles grant reading to any database. Commented Jun 10 at 16:08
  • 1
    MongoDB has various Backup Methods, and which method are you trying to use? Have you thought about creating a new user who can access all the tenant databases for backup (and perhaps, restore) process only. How many tenants are you expecting to work with is a factor in multi-tenant database architecture and administration; and there is this inherent complexity about maintaining the number of databases. Also, you may want to include the version and kind of cluster (standalone, replicaset, cloud, etc.) you are working with in your question.
    – prasad_
    Commented Jun 11 at 3:51


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.