方法一:
shell脚本
#!/bin/bash
#by fuqiang
#2018-09-04
cd /home/wenshu
mongodump --db wenshu --host xx.xx.xx.xx --port 29019 --username wenshu --password adffdeq --out=/home/wenshu/ >> /home/wenshu/mongodump.log
【备注】mongoexport会比mongodump速度快,实测;在3次测试过程中,当数据量大时,测试时用的440G,mongodump无故断掉进程。
方法二:
mongoexport -h [ip_address] -d [database] -c [collection] | mongoimport -h [ip_address] -d [database] -c [target]