
因為工作上需要用到改寫一套前端的 CMS系統,資料庫主要是 mongodb ,就記錄了一下如何備份及還原。
主要是透過 PowerShell 腳本指令操作 Mongodb tools,達成備份。
https://www.mongodb.com/try/download/database-tools
C:\Program Files\MongoDB\Tools\100\bin
mongodump --host 127.0.0.1 --port 27017 --authenticationDatabase admin --username mark --password pass.1234 --out ./test
P.S. 如果沒有特別指定驗證資料庫,就預設填 admin
mongorestore --host 127.0.0.1 --port 27017 --authenticationDatabase admin --username mark --password pass.1234 ---directoryperdb ./test