MongoDump / Mongo database backup
To export mongo database
Run this command in system command line not the mongo shell
C:\Program Files\MongoDB\Server\4.2\bin>mongodump 2020-07-13T22:53:09.443-0500 Failed: error dumping metadata: error creating directory for metadata file dump\Order: mkdir dump: Access is denied.
You may get this error if you don’t have correct permission to export database in that directory
To avoid this error , create a backup folder in your system and run mongodump command with file path
C:\Program Files\MongoDB\Server\4.2\bin>mongodump --out "c:\deldb" 2020-07-13T22:56:28.668-0500 writing admin.system.version to c:\deldb\admin\system.version.bson 2020-07-13T22:56:28.676-0500 done dumping admin.system.version (1 document) 2020-07-13T22:56:28.676-0500 writing Order.UserDetails to c:\deldb\Order\UserDetails.bson 2020-07-13T22:56:28.682-0500 done dumping Order.UserDetails (2 documents) 2020-07-13T22:56:28.980-0500 writing TestDb.TestDb to c:\deldb\TestDb\TestDb.bson 2020-07-13T22:56:28.987-0500 done dumping TestDb.TestDb (0 documents) C:\Program Files\MongoDB\Server\4.2\bin>
If you want to export particular database then you specify -d with database name
Note: -d database name is case-sensitive
C:\Program Files\MongoDB\Server\4.2\bin>mongodump -d order --out "c:\deldb" C:\Program Files\MongoDB\Server\4.2\bin>mongodump -d Order --out "c:\deldb" 2020-07-13T23:06:08.247-0500 writing Order.UserDetails to c:\deldb\Order\UserDetails.bson 2020-07-13T23:06:08.250-0500 done dumping Order.UserDetails (2 documents) C:\Program Files\MongoDB\Server\4.2\bin>