I've setup a backup script on my Ubuntu box using mongodump. However this currently doesn't work because of an error when attempting to dump the built in config database:
(Apologies for the image, I couldn't copy paste from the terminal I used)
How can I fix this? I either need to add the right permissions to my user, or exclude the config database. Ideally I'd like mongodump to ignore errors on any particular database so I still get a useful backup.
Here is the user I'm using to login as, as defined in the admin database:
{
"_id" : "admin.admin",
"userId" : UUID("b1928c55-fbaa-4196-9e7c-93e9139501ed"),
"user" : "admin",
"db" : "admin",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
},
{
"role" : "dbAdminAnyDatabase",
"db" : "admin"
},
{
"role" : "readWriteAnyDatabase",
"db" : "admin"
}
],
"mechanisms" : [
"SCRAM-SHA-1",
"SCRAM-SHA-256"
]
}
Best Answer
You don't have the required privileges for the config database.
See https://docs.mongodb.com/manual/reference/built-in-roles/ :
For mongodump, use the
backup
role.Specifics about mongodump https://docs.mongodb.com/manual/reference/program/mongodump/ :