Mongorestore error "don't know what to do with file... .bjson and .json"

I am trying to use the command line cmd mongorestore to restore a backup of a mongoDB database I have. Will this restore not work with the Atlas Cluster? The original DB was just a normal localized server database.

The error I am getting is:
don’t know what to do with file “/dev/channels.bson”, skipping…
don’t know what to do with file “/dev/channels.metadata.json”, skipping…

Any help would help! Thanks

It would help us help you if you provide the following information:

Version of the Atlas cluster you are restoring to
Version of mongorestore you are using
Was mongodump the same version?
Exact command you are running when you get this error.

Usually this happens when you point mongodump at a subdirectory inside the full dump without specifying which namespace you want it to restore to, but I’m just guessing - if you provide full details, it may be more clear what the issue is.


1 Like

Use -db flag in your mongorestore command


Thanks, it worked for me as well. But we need to pass command with -d insteed of -db.

1 Like

-d databaseName, now data will be restored in databaseName database.

@Ramachandra_Tummala I am facing same issue, i have used below command to restore

mongorestore --nsInclude dbname --ssl --host=“hostname:27017” --usernam
e= --password= --authenticationDatabase=admin --sslCAFile rds-combined-ca-bundle.pem --gzip /path/

Can you please help me on this issue?

just dbname will not work for nsInclude

Try nsInclude=“dbname.*”

Hi @Ramachandra_Tummala

I have tried as you said the above command i am getting same error, Please find the below restore command for your reference.

mongorestore --nsInclude="dbname" --ssl --host=“hostname:27017” --username=username --password=password --authenticationDatabase=admin --sslCAFile rds-combined-ca-bundle.pem /root/livedb/*

1 Like

Where is dbname.* in your command

If your are restoring one collection
If it is full DB you have to use wildcard (*)
Please check this link having some examples

I have used above command, and getting same thing, may be version problem?

I found this link provided one answer worked for me. Basically the folder given needs to be the root dump folder (i.e. “dump”) and the --nsInclude=“dbname.*” expects a folder called “dbname” under the “dump”.

Example of local db transfer:

mongodump --host=localhost --port=51896 --db dbname --out dump

The above command dumps all collections from database “dbname” unning at localhost:51896 into a subfolder like dump/dbname

mongorestore --host=localhost --port=27017 --nsInclude=“dbname.*” dump

The above command restores all collections under dump/dbname into the same “dbname” database running at localhost:27017.

If you need to use a different database name, then you just need to rename the “dbname” subfolder under dump to match your new database name.

mv dump/dbname dump/mynewdbname
mongorestore --host=localhost --port=27017 --nsInclude=“mynewdbname.*” dump

Hope this helps someone.