5

I'm trying to migrate my db over to a new machine. When I use mongodump in cmd it gives the error:

Failed: error dumping metadata: error creating directory for metadata file dump\margin_calls: mkdir dump: Access is denied.

I know I need to grant the 'backup' permission to allow this but I can't figure out how to do this.

EDIT: I thought this was quite an easy problem for someone familiar with the mongodb environment ?

David Hancock
  • 453
  • 1
  • 11
  • 24

2 Answers2

1

I ran into the same issue. It's because you do not have write permissions in the directory. You can change your command to:

    mongodump --out C:\Users\{YourUser}\Desktop

for example. So the backup dump is stored in a new folder in your desktop (change the path to store it in a different location).

Thanks to: https://stackoverflow.com/a/37510708/13811514 for the original post.

Antonio Gamiz Delgado
  • 1,871
  • 1
  • 12
  • 33
  • Hmm, Am having this same issue but the --out doesn't help. Have tried various directories and so mongodump will create a new directory for the backup alright but still fails on the metadata.json step with Access denied. – JKJ Jun 27 '20 at 08:55
  • Update to the above. Actually it finally worked when i tried "--out C:\". All kinds of various user directories would not work though. – JKJ Jun 27 '20 at 08:58
0

According to the documentation, there's a built-in backup role which is designed for this sort of thing:

> use admin
> db.createUser({
    user: "backupuser",
    pwd: "12345",
    roles: ["backup"]
}) 
ki9
  • 5,183
  • 5
  • 37
  • 48
  • The issue seems to be in the client filesystem permissions. (`mongodump` doesn't have permissions to create the dump file) I don't think there's any database change necessary at this point. – UltraMaster Mar 24 '19 at 08:51