-d需備份的數據庫名,-c需備份的表,-o輸出到哪一個文件夾,--authenticationDatabase保存用戶憑據的數據庫
mongodump --host IP_ADDRESS:27017 -u "root" -p "PASSWD" --authenticationDatabase "admin" -d DBname_test -o DBname_test20190328數據庫
mongorestore --host IP_ADDRESS:27017 -u "root" -p "PASSWD" --authenticationDatabase "admin" -d DBname_test DBname_test20190328json
mongoexport -h IP_ADDRESS -u root -p PASSWD --port 27017 --authenticationDatabase admin -d DB_name -c "COLLECTION_name" -o /root/COLLECTION_name.json --type json
db.getCollection('表名').find({"createdAt":{"$gte":ISODate("2019-10-15T00:00:00.000+08:00"),"$lte":ISODate("2019-10-30T00:00:00.000+08:00")}}).count();ide
mongoexport -h IPADDRESS -u saas -p "PASSWD" --port 217017 --authenticationDatabase admin -d saas -c "表名" -q '{createdAt:{$gte:new Date(1571068800000),$lte:new Date(1572364800000)}}' -o mongo$(date +%F).json --type jsonrest