在文件https://www.mongodb.com/docs/database-tools/mongodump/#data-exclusion中,有以下说明:
mongodump output only captures the documents in the database and does not include index data. mongorestore or mongod must then rebuild the indexes after restoring data.但是当我运行命令mongorestore --host=127.0.0.1:27018 --db=%dbname% --dir=%backup_path% --drop --objcheck --writeConcern="{w:1, wtimeout:500}" --stopOnError -vvvvv时有输出
2022-05-05T11:41:24.611+0800 restoring indexes for collection mongodb.FunctionParam from metadata
2022-05-05T11:41:24.611+0800 index: &idx.IndexDocument{Options:primitive.M{"background":true, "name":"id_1", "unique":true, "v":2}, Key:primitive.D{primitive.E{Key:"id", Value:1}}, PartialFilterExpression:primitive.D(nil)}
2022-05-05T11:41:24.612+0800 run create Index command for indexes: id_1发布于 2022-05-05 12:49:37
默认情况下,如果出于某种原因希望仅还原数据,则可以添加以下选项:
--noIndexRestore这将阻止mongorestore恢复和构建相应的mongodump输出中指定的索引。
https://stackoverflow.com/questions/72123724
复制相似问题