Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (50.2k points)

I want to migrate my mongodb from 2.0 to 3.0. So I followed the official doc to use mongodump to back up 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 are 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

1 Answer

0 votes
by (107k points)

The error seems to occur where you are calling mongorestore db on MongoDB 3.0.

You just have to specify the -d. Refer the following syntax:

Mongorestore -d db db

WHY -d?

This is because while updating, it might happen that the CLI interface has been changed or there might be some breakage in some code in updating so first we will be restoring the specific collection from the directory with the help of the -d and -c flags and then remove the flags from the specific collection and the -c flag and it will work and then you can easily import all the collections of the database.

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...