Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongorestore don't know what to do with file "db/collection.bson", skipping

Tags:

mongodb

I want to migrate my mongodb from 2.0 to 3.0. So I followed the official doc to use mongodump to backup my dbs and use mongorestore to restore the dbs to mongodb 3.0.

But when I use mongorestore, it tells me "don't know what to do with file "db/collection.bson", skipping...".

Nothing to do. How could I migrate my dbs?

Thanks.

EDIT: Here is my steps.

Use mongodump in mongodb 2.0

mongodump tree dump     db     ├── collection-1.bson     ├── collection-2.bson     ├── collection-3.bson     ├── ... 

Copy db directory to mongodb 3.0 server.

On the mongodb 3.0 server calls mongorestore db

But I get this error:

mongorestore db 2015-03-10T09:36:26.237+0800    building a list of dbs and collections   to restore from db dir 2015-03-10T09:36:26.237+0800    don't know what to do with file "db/collection-1.bson", skipping... 2015-03-10T09:36:26.237+0800    don't know what to do with file "db/collection-2.bson", skipping... 2015-03-10T09:36:26.237+0800    don't know what to do with file "db/collection-3.bson", skipping... ... 2015-03-10T09:36:26.237+0800    done 
like image 753
Feng Yu Avatar asked Mar 10 '15 01:03

Feng Yu


People also ask

Does Mongorestore overwrite data?

No. From mongorestore: If you restore to an existing database, mongorestore will only insert into the existing database, and does not perform updates of any kind. If existing documents have the same value _id field in the target database and collection, mongorestore will not overwrite those documents.

How do I restore a .GZ file in MongoDB?

You should just be able to do mongorestore --gzip <path to gzip folder). Side note you can use mongodump with --gzip option and it will compress it for you.

How do I run Mongorestore?

Basic mongorestore syntax The basic way to restore a database is to use the mongorestore command to specify the backup directory (dump directory) without any options. This option is suitable for databases located in the localhost (127.0. 0.1) using the port 27017.


2 Answers

It seems one must also specify -d in 3.0 like this:

mongorestore -d db db 
like image 63
Peter Avatar answered Sep 24 '22 16:09

Peter


This answer isn't directly related to your issue case, but the same error output you will receive trying to restore mongo data, dumped with --archive option, available since MongoDB 3.2 version. To resolve this you need to specify --gzip parameter in your mongorestore command. Example:

mongorestore -d destination_db --gzip /path/to/source/db 
like image 36
Artem Dolobanko Avatar answered Sep 23 '22 16:09

Artem Dolobanko