mongodb恢复似乎没有恢复所有文件

时间:2012-12-11 10:02:04

标签: mongodb mongorestore

在dump / enron目录中,messages.bson和messages.medata.json fiels。它应该恢复 120,477份文件。 我想从中恢复数据。 我输入命令:

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

命令完成后,我收到一条消息: 找到120477个物件 不知道如何处理文件[dump / enron / messages.metadata.json]

但是在收集信息中,我看到112196文件使用:

db.messages.count()

你能告诉我它有什么问题吗? 命令的输出:

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]

消息是什么:“不知道如何处理文件[dump / enron / messages.metadata.json]”是什么意思?

2 个答案:

答案 0 :(得分:3)

这应该有效:

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

答案 1 :(得分:1)

恢复bson文件时需要指定数据库和集合。

它对我有用:

$ 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

  $ 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

你可以尝试 -

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