How to take backup of MongoDB users and roles without data?

You probably can write a simple .js loop over all documents that calls https://docs.mongodb.com/manual/reference/method/db.createUser/.

Note that you do not get any password with db.getUsers() so you will have to generate new password.