mongorestore error: Don't know what to do with the dump file

MongodbMongo Shell

Mongodb Problem Overview


I have mongo DB installed in the following path c:\mongodb\bin. I have configured my environment variable PATH in advanced settings.I also have mongod running .When I run the following command mongorestore dump from the following path c:\hw1-1\dump (This contains the BSON files) I'm getting this error:

> Don't know what to do with the dump file

I have referred to this thread to check my path.

Mongodb Solutions


Solution 1 - Mongodb

in mongodb 3.0 or above, we should specify the database name to restore

mongorestore -d [your_db_name] [your_dump_dir]

Solution 2 - Mongodb

You probably saw this error:

> ERROR: don't know what to do with file [dump]

Which means in this case, that there is no file or directory called dump in your current working directory. So, Try this first cd c:/hw1-1/ (or whatever the correct syntax is on Windows, I can't test it.) Alternatively you can specify the full path to the dump directory:

mongorestore c:/hw1-1/dump

Solution 3 - Mongodb

If you're using mongoexport to create the dump, be sure to use mongoimport rather than mongorestore to load it.

Solution 4 - Mongodb

This error message "don't know what to do with file" can also occur if you have a BSON file that does not have a .bson file extension.

Generally this isn't a problem since mongodump generates the files with .bson extensions, but in my case I had a BSON file that was not generated by mongodump and had a different file extension.

Solution 5 - Mongodb

I'm on version 3.2 windows and my mongorestore seems to have a bug:

If I specify /db:database_name or /d database_name I get the error:

don't know what to do with subdirectory "dump\database_name", skipping...

Instead if I let it run on the whole dump directory it seems to work. The command I used is:

mongorestore /host:remote_host dump

My current directory structure is:

.
..
dump
dump\database_name

Solution 6 - Mongodb

I got this error when I had a collection matching the name of the one I was trying to restore present in Mongo ended up going into Mongo and deleting it using db.m101.drop();

Solution 7 - Mongodb

It took me some time to figure out the options for mongorestore , after i had kept getting this error for some time .

a) No running instances of mongod .

b) mongorestore -v -host localhost:27017 --dbpath "Actual Path for the Mongo DB- set in config" "Location where the dump is"

Using dbpath , allows to run this command without any running version of mongod . And this resolved my error .

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPrasanna AarthiView Question on Stackoverflow
Solution 1 - MongodbclevertensionView Answer on Stackoverflow
Solution 2 - MongodbMzzlView Answer on Stackoverflow
Solution 3 - MongodbpunkrockpollyView Answer on Stackoverflow
Solution 4 - MongodbhelmyView Answer on Stackoverflow
Solution 5 - MongodbAnton WolkovView Answer on Stackoverflow
Solution 6 - MongodbDonovan ThomsonView Answer on Stackoverflow
Solution 7 - MongodbRoshan KhandelwalView Answer on Stackoverflow