0
votes

I was trying mongodump to backup some dbs in mongodb and I have auth enabled in my mongodb.

I have one super user with role: "root" and db: "admin" and one with dbOwner for a specific db abc.

I tried this following command

mongodump --username admin --password "xyz" --authenticationDatabase admin


error - Failed: error dumping metadata: error creating directory for metadata file dump/abc: mkdir dump: permission denied

may be I need to use the credentials of the dbOwner but I thought being the super user one can do that.

Pls tell me how to use these two credentials in mongodump command.

2
The error comes from local filesystem, not from mongo. The user who runs mongodump command has no permission to create a directory dump in current directory. - Alex Blex
correct... that was really silly.........thanks - ts178

2 Answers

0
votes

You just follow:

Syntax:

mongodump -d <databasename> -o <target directory>

Example:

mongodump -d user -o ./desktop/foldername.

Where: the user is a collection name and -o is an output file and folder name is an where to store in the file.

0
votes

I had the same issue and I found this answer posted by kallko on Gihtub which helps me.

So to resolve it, you need to add a sudo just before the command and that's it. It works for me.

Hope it helps !