Skip to content
Advertisement

How to backup a mongodb database with authorization enabled?

I am running a mongo database on Digital Ocean. I’ve set it up with the following tutorial: Mongodb setup and secured it with this tutorial: MongoDb security

Now I am trying to create a dump of a particular database. I am using the following command as stated in this article: Backup & Restore Mongodb:

sudo mongodump --db dbName --out /var/backups/mongobackups/date +”%m-%d-%y”“

However, I am getting the following error message:

Failed: error getting collections for database 'dbName': error running 'listCollections'. Database: 'dbName' Err: command listCollections requires authentication.

I’ve logged in on my server with root user. What am I missing?

Advertisement

Answer

As the error clearly says “command listCollections requires authentication.” you should try “Dump database with username & password mongodump -u=USERNAME -p=PASSWORD –db=DB_NAME.”

🙂

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement