在Linux系统上恢复MongoDB数据主要有以下两种常用方式:
mongorestore工具(逻辑/物理恢复)sudo systemctl stop mongod
/var/lib/mongodb)。mongorestore --host <主机名> --port<端口> <备份目录> [<数据库名>]
test的数据库):mongorestore --host localhost --port 27017 /backup/test
--drop参数。sudo systemctl start mongod
若启用了复制集或OPLOG,可通过OPLOG记录的写操作恢复数据(需结合mongodump备份和OPLOG工具,操作较复杂,建议参考官方文档)。
--username、--password及--authenticationDatabase参数。mongodb用户)。详细操作可参考:MongoDB官方恢复文档。