4、MongoDB學習之備份還原
阿新 • • 發佈:2017-09-09
img com 名稱 mon oot res 全量 metadata src 一、MongoDB備份
1、MongoDB整庫備份
備份數據使用下面的命令
mongodump -h dbhost -d dbname -o dbdirectory
備份user數據庫
[[email protected] bin]# ./mongodump -h127.0.0.1 -d user -o /home/
[[email protected] bin]# ls /home/user/ b3.bson b3.metadata.json c1.bson c1.metadata.json #可以看到備份的文件了 2、MongoDB單個集合備份 備份test庫下面的c1集合 [[email protected] bin]# ./mongodump -h127.0.0.1 -d test -c c1 -o /tmp/
二、MongoDB還原 1;單庫還原 [[email protected] bin]# ./mongorestore -h 127.0.0.1:27017 -d user /home/user/ #客戶端查看到整個user數據庫已經還原成功了
2;單集合還原 [[email protected] bin]# ./mongorestore -h 127.0.0.1:27017 -d test /tmp/test/ #單集合還原也是不需要制定具體集合名稱
總結:mongodb以上備份還原只針對全量備份,增量備份後續還需要研究
4、MongoDB學習之備份還原