1

The title sums it up nicely. Essentially what I am asking is, if its possible to backup (use mongodump perhaps?) only users (accounts created for human users)?

  • 2
    It should be possible to backup just collection admin.system.users – Wernfried Domscheit Jan 27 at 20:16
  • @WernfriedDomscheit actually turns out you cant. Read my answer to the question for more info. – marxmacher Jan 28 at 11:40
1

So after digging around further i found how to do that.

In short i needed to take the system.users collection or rather use a query to get only users from that collection that follow a certain pattern. for me it was user@some.domain, without the query i would have gotten all service users also which i did not want or need.

The tricky part was mongorestore which did not work if i wanted to restore only the system.users collection

The error i got was:

2020-01-28T12:44:49.902+0200    assuming users in the dump directory are from <= 2.4 (auth version 1)
2020-01-28T12:44:49.960+0200    Failed: the users and roles collections in the dump have an incompatible auth version with target server: cannot restore users of auth version 1 to a server of auth version 5
2020-01-28T12:44:49.960+0200    0 document(s) restored successfully. 0 document(s) failed to restore.

I got the error because mongorestore is unable to determine the version of the dump mongo if you dont give it system.version collection also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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