mongodb数据库的备份与恢复
先介紹下命令語法:
./mongodump -h 127.0.0.1:10001 -d lietou -o /usr/local/data
?
-h:MongDB所在服務(wù)器地址,例如:127.0.0.1,當(dāng)然也可以指定端口號(hào):127.0.0.1:10001
-d:需要備份的數(shù)據(jù)庫實(shí)例,例如:lietou
-o:備份的數(shù)據(jù)存放位置,例如:/usr/local/data?,在備份完成后,系統(tǒng)自動(dòng)在dump目錄下建立一個(gè)lietou目錄,這個(gè)目錄里面存放該數(shù)據(jù)庫實(shí)例的備份數(shù)據(jù)。
數(shù)據(jù)庫還原
./mongorestore -h 127.0.0.1:10001 -d test ?--directoryperdb /usr/local/data/lietou/
?
h:MongoDB所在服務(wù)器地址
-d:需要恢復(fù)的數(shù)據(jù)庫實(shí)例,例如:test,當(dāng)然這個(gè)名稱也可以和備份時(shí)候的不一樣,比如test2
--directoryperdb:備份數(shù)據(jù)所在位置,例如:/usr/local/data/lietou/,這里為什么要多加一個(gè)lietou,而不是備份時(shí)候的dump,讀者自己查看提示吧!
--drop:恢復(fù)的時(shí)候,先刪除當(dāng)前數(shù)據(jù),然后恢復(fù)備份的數(shù)據(jù)。就是說,恢復(fù)后,備份后添加修改的數(shù)據(jù)都會(huì)被刪除,慎用哦!
轉(zhuǎn)載于:https://www.cnblogs.com/smallstupidwife/p/4836816.html
總結(jié)
以上是生活随笔為你收集整理的mongodb数据库的备份与恢复的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: poj 2390 Bank Intere
- 下一篇: Jenkins自定义主题