I want to migrate from one cluster to another. So I'm goint go make a backup with mongodump and mongorestore. Db is not so big, so I would like to disable writes on source db before the start to exclude accidental writes from apps.

What would be the best way to do this?

2 Answers 2


There are two similar options available, based on user permissions.

  1. For the user which your application uses to connect to the DB (let's call it applicationConnUser), change its permissions: for example if it currently has the readWrite role, revoke that and grant the read role instead.
  2. Set up a different user - leave applicationConUser unchanged and create a new account applicationConUserReadOnly to which you grant the read role - and reconfigure your application to connect with this account instead.

Note that your application may not react helpfully when its normal operations cannot write to the database; depending on how it is coded, it may crash out as soon as it gets a db error.

  • Thanks for the answer. Is it possible to change permissions remotely via cli?
    Commented Jun 14, 2018 at 12:48
  • Yes, all the commands to do with granting and revoking roles can be executed through the command-line mongo shell. Commented Jun 14, 2018 at 14:54

For those using more up-to-date versions of MongoDB you may want to take a look at db.fsynclock()

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.