MongoDB Data Backup and recovery

Source: Internet
Author: User
Tags mongodump

Test environment: Windows

I. Exporting data
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

Import file: Parameter keyword can not be used-, can only use/.
JSON format
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 format
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%)
2015-12-02t15:27:12.945+0800 Imported 110002 Documents

Backup files
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)

Summarize:
1. Data backup can be in a variety of format files, support Csv,json and other formats.
2. Support Dump mode

MongoDB Data Backup and recovery

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.