把阿里云mongodb备份到本地

IT
IT
IT
285
文章
1
评论
2020年5月21日14:02:51 评论 115 6139字阅读20分27秒

把阿里云mongodb备份到本地

直接使用mongodump即可

[root@izbp18yfs65r3chh1modvaz ~]# mongodump --host dds-bp1f887ea875a6e41.mongodb.rds.aliyuncs.com:3717 --authenticationDatabase admin -u root -p BIgsfintech20185101

前提是你那台机器安装了mongodb和启动了mongodb

导出成功如下

 

2018-04-23T17:15:56.328+0800 [########################] antifraud_log_anatomy.antifraud_raw_input_data 253886/253886 (100.0%)
2018-04-23T17:15:56.328+0800 done dumping antifraud_log_anatomy.antifraud_raw_input_data (253886 documents)
2018-04-23T17:15:57.154+0800 [########################] data_product.daf170401_supplyandquery 256124/256124 (100.0%)
2018-04-23T17:15:57.154+0800 done dumping data_product.daf170401_supplyandquery (256124 documents)
2018-04-23T17:15:57.515+0800 [################........] data_product.vaf161101_operator_variables 121009/173545 (69.7%)
2018-04-23T17:16:00.515+0800 [#################.......] data_product.vaf161101_operator_variables 123898/173545 (71.4%)
2018-04-23T17:16:03.515+0800 [##################......] data_product.vaf161101_operator_variables 130530/173545 (75.2%)
2018-04-23T17:16:06.515+0800 [##################......] data_product.vaf161101_operator_variables 135163/173545 (77.9%)
2018-04-23T17:16:09.515+0800 [###################.....] data_product.vaf161101_operator_variables 143169/173545 (82.5%)
2018-04-23T17:16:12.515+0800 [####################....] data_product.vaf161101_operator_variables 151807/173545 (87.5%)
2018-04-23T17:16:15.515+0800 [#####################...] data_product.vaf161101_operator_variables 158002/173545 (91.0%)
2018-04-23T17:16:18.515+0800 [######################..] data_product.vaf161101_operator_variables 165257/173545 (95.2%)
2018-04-23T17:16:21.232+0800 [########################] data_product.vaf161101_operator_variables 173545/173545 (100.0%)
2018-04-23T17:16:21.232+0800 done dumping data_product.vaf161101_operator_variables (173545 documents)
[root@izbp18yfs65r3chh1modvaz ~]# ll
total 4
drwxr-xr-x 8 root root 4096 Apr 23 17:12 dump
[root@izbp18yfs65r3chh1modvaz ~]#

恢复到本地,先打包下载到本地

[root@izbp18yfs65r3chh1modvaz ~]# tar czvf dump.tar.gz dump
dump/
dump/admin/
dump/admin/system.version.metadata.json
dump/admin/system.version.bson
dump/admin/system.users.metadata.json
dump/admin/system.users.bson
dump/data_product/
dump/data_product/vcd170502_HF_variables.bson
dump/data_product/vcd170601_tb_variables.metadata.json
dump/data_product/daf170401_supplyandquery.bson

解压后进行数据恢复

[root@localhost ~]# mongorestore -h 127.0.0.1 --port 27017 --drop /root/dump
2018-04-23T18:43:16.936+0800 preparing collections to restore from
2018-04-23T18:43:16.942+0800 reading metadata for data_product.vaf161101_operator_variables from /root/dump/data_product/vaf161101_operator_variables.metadata.json
2018-04-23T18:43:16.943+0800 reading metadata for antifraud_log_anatomy.antifraud_raw_input_data from /root/dump/antifraud_log_anatomy/antifraud_raw_input_data.metadata.json
2018-04-23T18:43:16.944+0800 reading metadata for app_db.app_tb from /root/dump/app_db/app_tb.metadata.json
2018-04-23T18:43:16.944+0800 reading metadata for metaData_prod.dataSource from /root/dump/metaData_prod/dataSource.metadata.json
2018-04-23T18:43:16.990+0800 restoring app_db.app_tb from /root/dump/app_db/app_tb.bson
2018-04-23T18:43:16.990+0800 restoring metaData_prod.dataSource from /root/dump/metaData_prod/dataSource.bson
2018-04-23T18:43:16.990+0800 restoring antifraud_log_anatomy.antifraud_raw_input_data from /root/dump/antifraud_log_anatomy/antifraud_raw_input_data.bson
2018-04-23T18:43:16.990+0800 restoring data_product.vaf161101_operator_variables from /root/dump/data_product/vaf161101_operator_variables.bson
2018-04-23T18:43:16.998+0800 no indexes to restore
2018-04-23T18:43:16.998+0800 finished restoring metaData_prod.dataSource (1 document)
2018-04-23T18:43:16.999+0800 reading metadata for test.app_tb from /root/dump/test/app_tb.metadata.json
2018-04-23T18:43:17.002+0800 restoring test.app_tb from /root/dump/test/app_tb.bson
2018-04-23T18:43:17.008+0800 no indexes to restore
2018-04-23T18:43:17.008+0800 finished restoring test.app_tb (2 documents)
2018-04-23T18:43:17.008+0800 reading metadata for metaData_prod.dbInfo from /root/dump/metaData_prod/dbInfo.metadata.json
2018-04-23T18:43:17.044+0800 restoring metaData_prod.dbInfo from /root/dump/metaData_prod/dbInfo.bson
2018-04-23T18:43:17.052+0800 no indexes to restore
2018-04-23T18:43:17.052+0800 finished restoring metaData_prod.dbInfo (0 documents)
2018-04-23T18:43:17.052+0800 reading metadata for metaData_prod.tableInfo from /root/dump/metaData_prod/tableInfo.metadata.json
2018-04-23T18:43:17.101+0800 restoring metaData_prod.tableInfo from /root/dump/metaData_prod/tableInfo.bson
2018-04-23T18:43:17.101+0800 no indexes to restore
2018-04-23T18:43:17.101+0800 finished restoring metaData_prod.tableInfo (0 documents)
2018-04-23T18:43:17.102+0800 reading metadata for data_product.daf170401_supplyandquery from /root/dump/data_product/daf170401_supplyandquery.metadata.json
2018-04-23T18:43:17.135+0800 restoring data_product.daf170401_supplyandquery from /root/dump/data_product/daf170401_supplyandquery.bson
2018-04-23T18:43:19.937+0800 [#.......................] antifraud_log_anatomy.antifraud_raw_input_data 189MB/3.28GB (5.6%)
2018-04-23T18:43:19.937+0800 [#.......................] app_db.app_tb 141MB/1.91GB (7.2%)
2018-04-23T18:43:19.937+0800 [#.......................] data_product.vaf161101_operator_variables 177MB/3.67GB (4.7%)
2018-04-23T18:43:19.937+0800 [#.......................] data_product.daf170401_supplyandquery 193MB/3.27GB (5.8%)
2018-04-23T18:43:19.937+0800
2018-04-23T18:43:22.939+0800 [##......................] antifraud_log_anatomy.antifraud_raw_input_data 375MB/3.28GB (11.2%)
2018-04-23T18:43:22.939+0800 [###.....................] app_db.app_tb 293MB/1.91GB (15.0%)
2018-04-23T18:43:22.939+0800 [##......................] data_product.vaf161101_operator_variables 354MB/3.67GB (9.4%)
2018-04-23T18:43:22.939+0800 [##......................] data_product.daf170401_supplyandquery 410MB/3.27GB (12.2%)
2018-04-23T18:43:22.939+0800
2018-04-23T18:43:25.928+0800 [##......................] antifraud_log_anatomy.antifraud_raw_input_data 401MB/3.28GB (11.9%)
2018-04-23T18:43:25.928+0800 [###.....................] app_db.app_tb 313MB/1.91GB (16.0%)
2018-04-23T18:43:25.928+0800 [##......................] data_product.vaf161101_operator_variables 379MB/3.67GB (10.1%)
2018-04-23T18:43:25.928+0800 [###.....................] data_product.daf170401_supplyandquery 440MB/3.27GB (13.2%)

 

继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2020年5月21日14:02:51
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
WEB管理MongoDB MongoDB

WEB管理MongoDB

安装 创建文件 # mkdir -p /usr/local/node # chmod 777 /usr/local/node 安装nodejs # wget https://npm.taobao.or...
yum安装MongoDB MongoDB

yum安装MongoDB

Configure the package management system (yum) # vim /etc/yum.repos.d/mongodb-org-4.2.repo name=Mongo...