'How to Clone/Copy a mongodb database using mongodump on an AWS ECS server

I have ssh into an AWS EC2 instance MongoDB database that has a password and username and I need to duplicate the database called admin. To show that the database exists, first i enter the MongoDB shell by using the command below

mongo --port 27017 -u "admin" -p "*******" --authenticationDatabase "admin"

after entering the mongoshell i can run "show dbs" command and the databases are listed. This is an indication that the password and user are correct.

Now the problem is an auth error when i try to use mongodbdump. Below is the command I use

mongodump  --port 27017 -u "admin" -p "*******" --authenticationDatabase "admin"  --archive="mongodump-admin-db" --db=admin

Below is the auth error i get yet I am sure that the credentials are correct

Failed: error creating intents to dump: error counting admin.system.views: (Unauthorized) not authorized on admin to execute command { count: "system.views", lsid: { id: UUID("5e8e1d85-76c7-4a1c-854f-4ea90573d3d9") }, $db: "admin" }

As of now, I am using the Mongodump documentation here.

Kindly help on on how I can solve this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source