[英]How to restore dump backup in mongodb
我有 restore-63bbdc996664dc2524cce24d.tar 文件,我正在 MongoDB 數據庫中恢復它
試過這些命令
mongodump --db test --gzip --archive=restore-63bbdc996664dc2524cce24d.tar
mongodump --db 測試 --archive=restore-63bbdc996664dc2524cce24d.tar
mongodump --host localhost --port 27017 --db test --gzip --archive=restore-63bbdc996664dc2524cce24d.tar
mongorestore --drop C:\Users\rustam\restore-63bbdc996664dc2524cce24d.tar.gz -v
錯誤=> 失敗:文件 C:\Users\rustam\restore-63bbdc996664dc2524cce24d.tar.gz 沒有 .bson 擴展名
我還嘗試通過命令將此文件轉換為 bson
bsondump --outFile=C:\Users\rustam\restore-63bbdc996664dc2524cce24d.tar.gz coll.bson
誰能告訴我我應該怎么做才能恢復數據庫?
提前感謝您的任何評論或回答。
花了很多時間之后終於找到了解決方案
1. Extract the tar file
2. Run the below command
mongod --port your_port --dbpath your_extracted_tar_folder
note: port is optional, it will run 27027 default port
3. Go and connect on the same port that you pass
tar -xvf restore-63bbdc996664dc2524cce24d.tar
提取存檔文件mongorestore --db test --drop <path/to/extracted/bson/files>
恢復轉儲。請記住,此命令將在還原之前刪除該數據庫中任何現有的 collections,因此請確保您已進行必要的備份。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.