MongoDB数据库备份
mongodump -h dbhost -d dbname -o dbdirectory
-h: 服务器地址,也可以指定端口号
-d: 需要备份的数据库名称
-o: 备份的数据存放位置,此目录中存放着备份出来的数据
例如:
mongodump -h 192.168.19.25:27017 -d test1 -o ~/Desktop/test1bak
MongoDB数据库恢复
mongorestore -h dbhost -d dbname --dir dbdirectory
-h: 服务器地址
-d: 需要恢复的数据库实例
--dir:备份数据所在位置
例如:
mongorestore -h 192.168.19.25:27017 -d test2 --dir ~/Desktop/test1bak/test1