Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongo DB and inserting bson files into a database

Tags:

mongodb

I was given a data dump of bson files. In the mongo db, the database and the collections exists. These are updates to each of the collections in the database. So, in the given directory, there are about 30 bson files for each collection.

From the command line, I am using ubuntu, how do I append and load? Mongo is on my localhost with no username or password.

Thanks

like image 477
Tampa Avatar asked Aug 05 '12 15:08

Tampa


1 Answers

Took me a while to get around this excuse for an error. In the end I went to the directory outside of my dump folder, and did the following...

For a full DB restore:

mongorestore --drop dump/mydb

Note that the mongodump operation will create individual folders for each database within the dump folder it creates, so you need to specify the full relative path, as above.

For a single collection:

mongorestore --drop -d mydb -c mycollection dump/mydb/mycollection.bson

like image 118
Engineer Avatar answered Oct 06 '22 14:10

Engineer