首页 / MONGODB / MongoDB数据备份与恢复
MongoDB数据备份与恢复
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MongoDB数据备份与恢复,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4301字,纯文字阅读大概需要7分钟。
内容图文
测试环境:windows
一. 导出数据
F:\DbSoft\soft\master\bin>mongoexport /h 127.0.0.1 /port 50000 /d testdb /c tb1
--type=csv /f _id,name,age /o F:\DbSoft\mongodb\export_file\abc.dat
2015-12-02T15:01:06.787+0800 connected to: 127.0.0.1:50000
2015-12-02T15:01:10.371+0800 exported 110002 records
F:\DbSoft\soft\master\bin>mongoexport /h 127.0.0.1 /port 50000 /d testdb /c tb1
--type=json /f _id,name,age /o F:\DbSoft\mongodb\export_file\abcd.dat
2015-12-02T15:02:01.096+0800 connected to: 127.0.0.1:50000
2015-12-02T15:02:05.959+0800 exported 110002 records
导入文件:参数关键字不能用-,只能用/.
json格式
F:\DbSoft\soft\master\bin>mongoimport /h 127.0.0.1 /port 50000 /d testdb /c tb2
F:\DbSoft\mongodb\export_file\abcd.dat
2015-12-02T15:09:40.749+0800 connected to: 127.0.0.1:50000
2015-12-02T15:09:43.700+0800 [##......................] testdb.tb2 946.1 KB
/7.7 MB (12.0%)
2015-12-02T15:09:46.681+0800 [########................] testdb.tb2 2.7 MB/7
.7 MB (35.1%)
2015-12-02T15:09:49.681+0800 [###############.........] testdb.tb2 4.8 MB/7
.7 MB (62.9%)
2015-12-02T15:09:52.720+0800 [##################......] testdb.tb2 6.1 MB/7
.7 MB (79.1%)
2015-12-02T15:09:55.577+0800 imported 110002 documents
Csv格式
F:\DbSoft\soft\master\bin>mongoimport /host 127.0.0.1:50000 /d testdb /c tb3 /ty
pe csv /headerline /file F:\DbSoft\mongodb\export_file\abc.dat
2015-12-02T15:27:00.252+0800 connected to: 127.0.0.1:50000
2015-12-02T15:27:03.230+0800 [######..................] testdb.tb3 1.4 MB/5
.3 MB (26.3%)
2015-12-02T15:27:06.261+0800 [############............] testdb.tb3 2.8 MB/5
.3 MB (53.9%)
2015-12-02T15:27:09.242+0800 [##################......] testdb.tb3 4.1 MB/5
.3 MB (78.2%)
2015-12-02T15:27:12.226+0800 [########################] testdb.tb3 5.3 MB/5
.3 MB (100.0%)
2015-12-02T15:27:12.945+0800 imported 110002 documents
备份文件
F:\DbSoft\soft\master\bin>mongodump /host 127.0.0.1:50000 /d testdb /o F:\DbSof
t\mongodb\export_file\dump1.dat
2015-12-02T15:34:48.542+0800 writing testdb.tb1 to F:\DbSoft\mongodb\export_f
ile\dump1.dat\testdb\tb1.bson
2015-12-02T15:34:48.594+0800 writing testdb.tb2 to F:\DbSoft\mongodb\export_f
ile\dump1.dat\testdb\tb2.bson
2015-12-02T15:34:48.708+0800 writing testdb.ta1 to F:\DbSoft\mongodb\export_f
ile\dump1.dat\testdb\ta1.bson
2015-12-02T15:34:48.710+0800 writing testdb.tb3 to F:\DbSoft\mongodb\export_f
ile\dump1.dat\testdb\tb3.bson
2015-12-02T15:34:51.602+0800 [####....................] testdb.tb1 20778/11
0002 (18.9%)
2015-12-02T15:34:51.650+0800 [########................] testdb.tb2 37789/11
0002 (34.4%)
2015-12-02T15:34:51.664+0800 [############............] testdb.tb3 55181/11
0002 (50.2%)
2015-12-02T15:34:51.678+0800 [........................] testdb.ta1 101/10
0001 (0.1%)
2015-12-02T15:34:51.679+0800
2015-12-02T15:34:52.454+0800 writing testdb.tb3 metadata to F:\DbSoft\mongodb
\export_file\dump1.dat\testdb\tb3.metadata.json
2015-12-02T15:34:52.601+0800 done dumping testdb.tb3 (110002 documents)
2015-12-02T15:34:52.875+0800 writing testdb.system.indexes to F:\DbSoft\mongo
db\export_file\dump1.dat\testdb\system.indexes.bson
2015-12-02T15:34:53.177+0800 writing testdb.tb2 metadata to F:\DbSoft\mongodb
\export_file\dump1.dat\testdb\tb2.metadata.json
2015-12-02T15:34:53.197+0800 writing testdb.tb1 metadata to F:\DbSoft\mongodb
\export_file\dump1.dat\testdb\tb1.metadata.json
2015-12-02T15:34:53.202+0800 done dumping testdb.tb2 (110002 documents)
2015-12-02T15:34:54.265+0800 done dumping testdb.tb1 (110002 documents)
2015-12-02T15:34:54.543+0800 [........................] testdb.ta1 101/1000
01 (0.1%)
2015-12-02T15:34:55.819+0800 writing testdb.ta1 metadata to F:\DbSoft\mongodb
\export_file\dump1.dat\testdb\ta1.metadata.json
2015-12-02T15:34:55.820+0800 done dumping testdb.ta1 (100001 documents)
F:\DbSoft\soft\master\bin>mongodump /host 127.0.0.1:50000 /d testdb /c tb3 /o F
:\DbSoft\mongodb\export_file\dump2.dat
2015-12-02T15:44:49.780+0800 writing testdb.tb3 to F:\DbSoft\mongodb\export_f
ile\dump2.dat\testdb\tb3.bson
2015-12-02T15:44:50.767+0800 writing testdb.tb3 metadata to F:\DbSoft\mongodb
\export_file\dump2.dat\testdb\tb3.metadata.json
2015-12-02T15:44:50.770+0800 done dumping testdb.tb3 (110002 documents)
总结:
1.数据备份可以采用多种格式文件,支持csv,json等格式。
2.支持dump方式
MongoDB数据备份与恢复
标签:
本文系统来源:http://www.cnblogs.com/myibm/p/5939345.html
内容总结
以上是互联网集市为您收集整理的MongoDB数据备份与恢复全部内容,希望文章能够帮你解决MongoDB数据备份与恢复所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。