0

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.

ts178
  • 321
  • 1
  • 6
  • 20
  • 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 Jun 26 '18 at 13:44
  • correct... that was really silly.........thanks – ts178 Jun 26 '18 at 13:58

2 Answers2

1

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 !

phenric
  • 307
  • 1
  • 8
  • 15
0

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.

amod
  • 4,190
  • 10
  • 49
  • 75
Sekar
  • 24
  • 2