Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the dumped data by mongodump?

I have used mongodump to dump my database of mongodb, it created some bson files under dump/mydb

But I don't know how to use them. I tried mongoimport, but seems it can't import bson data. Then how to use these bson files? How to import them to another mongodb?

like image 390
Freewind Avatar asked Mar 31 '11 05:03

Freewind


People also ask

How recover data from Mongodump?

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.

What is the use of Mongodump?

The mongodump is a utility for creating database backups. The utility can be used for creating binary export of the database contents. Mongodump can export data from both mongod and mongos instances, allowing you to create backups from: A standalone, replica set.

Does Mongodump lock the database?

Mongdump does not lock the db. It means other read and write operations will continue normally.


1 Answers

You need to use mongorestore, not mongoimport ... which is used for things like importing json, or csv, etc.

From the back-up-with-mongodump docs:

mongodump reads data from a MongoDB database and creates high fidelity BSON files which the mongorestore tool can use to populate a MongoDB database.

mongodump and mongorestore are simple and efficient tools for backing up and restoring small MongoDB deployments, but are not ideal for capturing backups of larger systems.

You can read more about mongorestore in the docs below; I'd take a look and read up on them as they are very helpful.

http://www.mongodb.org/display/DOCS/Import+Export+Tools#ImportExportTools-mongorestore

You can also check out http://learnmongo.com for tips and help!

like image 137
Justin Jenkins Avatar answered Oct 12 '22 13:10

Justin Jenkins