在Debian上恢复MongoDB数据,主要使用mongorestore工具,步骤如下:
sudo systemctl stop mongod
mongorestore --db 数据库名 /path/to/backup/数据库名
mongorestore --db 数据库名 --collection 集合名 /path/to/backup/数据库名/集合名.bson
mongorestore --oplogReplay /path/to/backup
sudo systemctl start mongod
mongo客户端连接数据库,检查数据是否正确恢复。注意:
mongodb用户或具备足够权限的用户。