Oleg
Oleg

Reputation: 2821

mongodbrestore don't seem to restore all documents

In dump/enron directory messages.bson and messages.medata.json fiels. It should restore 120,477 documents. I want to restore data from it. I input command:

mongorestore -v --db enron --drop  dump/enron

After command is finished I get a messagee: 120477 objects found don't know what to do with file [dump/enron/messages.metadata.json]

But in the collection message I see 112196 documents using:

db.messages.count()

Could you please tell me what's the problem with it? The output of the command:

c:\mongodb\mongodb-win32-i386-2.0.5\bin>mongorestore -v  dump/enron/
Tue Dec 11 14:17:39 creating new connection to:127.0.0.1
Tue Dec 11 14:17:39 BackgroundJob starting: ConnectBG
Tue Dec 11 14:17:39 connected connection!
connected to: 127.0.0.1
Tue Dec 11 14:17:39 dump/enron/messages.bson
Tue Dec 11 14:17:39      going into namespace [enron.messages]
Tue Dec 11 14:17:39      file size: 396236668
                126878231/396236668     32%
                270206614/396236668     68%
                375698921/396236668     94%
                381433738/396236668     96%
                387378348/396236668     97%
                394626836/396236668     99%
120477 objects found
don't know what to do with file [dump/enron/messages.metadata.json]

What does the message: "don't know what to do with file [dump/enron/messages.metadata.json]" mean?

Upvotes: 2

Views: 6654

Answers (2)

user1010101010
user1010101010

Reputation: 41

This should work:

ssharma$ mongorestore -d enron --collection messages /dump/enron/messages.bson
connected to: 127.0.0.1
Thu Mar  7 13:05:05 /dump/enron/messages.bson
Thu Mar  7 13:05:05     going into namespace [enron.messages]
Thu Mar  7 13:05:09         74234213/396236668  18% (bytes)
Thu Mar  7 13:05:12         126614885/396236668 31% (bytes)
Thu Mar  7 13:05:15         192098158/396236668 48% (bytes)
Thu Mar  7 13:05:18         208083274/396236668 52% (bytes)
Thu Mar  7 13:05:21         231816712/396236668 58% (bytes)
Thu Mar  7 13:05:24         293564538/396236668 74% (bytes)
Thu Mar  7 13:05:27         356071219/396236668 89% (bytes)
Thu Mar  7 13:05:30         379387449/396236668 95% (bytes)
120477 objects found
Thu Mar  7 13:05:32     Creating index: { key: { _id: 1 }, ns: "enron.messages", name: "_id_" }
ssharma$ ./mongo
MongoDB shell version: 2.2.2
connecting to: test
> use enron
switched to db enron
> db.messages.count()
120477

Upvotes: 4

Mark Hillick
Mark Hillick

Reputation: 6973

You need to specify the database and the collection when restoring the bson file.

It works for me like so:

$ mongodump -d mark --collection coll 
connected to: 127.0.0.1
DATABASE: mark   to     dump/mark
    mark.coll to dump/mark/coll.bson
         1000 objects

and

  $ mongorestore -d mark --collection newcoll dump/mark/
    connected to: 127.0.0.1
    Wed Aug 29 11:48:39 dump/mark/coll.bson
    Wed Aug 29 11:48:39      going into namespace [mark.newcoll]
    1000 objects found

Can you try -

mongorestore -d enron --collection messages /dump/enron/

Upvotes: 1

Related Questions