0
votes

I am brand new to Mongo and have just set up my first MongoDB Instance/Server. We must run this as secure as possible when it goes to production, so I am running it in secure mode. I am trying to get backups working.

This is also my first post in this forum. Please bear with me.

The command I used: mongodump --host=localhost --port=27017 --username=useradmin --authenticationDatabase=admin --out=/opt/mongodb/bkup/mongodump-date +%m%d%yyyy%H%M.

I get: 2020-05-11T14:17:06.087-0500 Failed: error creating intents to dump: error creating intents for database admin: error getting collections for database admin: (Unauthorized) not authorized on admin to execute command { listCollections: 1, filter: {}, lsid: { id: UUID("b524c139-54d1-4789-a2b3-2eb88bb37255") }, $db: "admin" }

I know my authentication works because I can connect with: [root@svldstkdb01 bin]# mongo svldstkdb01/admin -u useradmin -p MongoDB shell version v4.2.6 Enter password: connecting to: mongodb://svldstkdb01:27017/admin?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("cc5b1b24-dc00-437d-ae56-6aef53018589") } MongoDB server version: 4.2.6

show dbs admin 0.000GB <-- useradmin account is here config 0.000GB local 0.000GB stkdb 0.000GB <-- I also need to back up this DB.

Questions:

1) Do I need to create an admin account to backup all DBs? - Please give an example to create such an account. 2) Is there a way to backup all DBs in the instance?

1

1 Answers

1
votes

You can create a backup role which provides necessary permissions to do mongodump. To create an user follow example here with role as "backup" or grant existing user backup role