Mongodb

無法使用 mongorestore 恢復 mongodump archivegz 文件

  • February 11, 2022

我生成了一個具有該archivegz格式的 MongoDB 轉儲文件。當我嘗試使用mongorestore命令恢復它時,它不會恢復。

恢復命令

mongorestore --gzip --archive="./mongo_device.bing.com_20220209-000000.archivegz" --db=Test --verbose

結果

2022-02-10T11:57:02.955+0330    using write concern: &{majority false 0}
2022-02-10T11:57:03.587+0330    will listen for SIGTERM, SIGINT, and SIGKILL
2022-02-10T11:57:03.588+0330    connected to node type: standalone
2022-02-10T11:57:03.588+0330    The --db and --collection flags are deprecated for this use-case; please use --nsInclude instead, i.e. with --nsInclude=${DATABASE}.${COLLECTION}
2022-02-10T11:57:03.740+0330    archive prelude Logger.logs
2022-02-10T11:57:03.740+0330    archive prelude Logger.DeviceChannelData
2022-02-10T11:57:03.740+0330    archive format version "0.1"
2022-02-10T11:57:03.740+0330    archive server version "4.4.3"
2022-02-10T11:57:03.740+0330    archive tool version "v3.15.0_alpha20210804-4411-g6ef8a4d4d7"
2022-02-10T11:57:03.741+0330    preparing collections to restore from
2022-02-10T11:57:03.741+0330    skipping restoring Logger.logs, it is not included
2022-02-10T11:57:03.741+0330    skipping restoring Logger.logs metadata, it is not included
2022-02-10T11:57:03.742+0330    skipping restoring Logger.DeviceChannelData, it is not included
2022-02-10T11:57:03.742+0330    skipping restoring Logger.DeviceChannelData metadata, it is not included
2022-02-10T11:57:04.208+0330    demux finishing (err:<nil>)
2022-02-10T11:57:04.208+0330    received  from namespaceChan
2022-02-10T11:57:04.208+0330    restoring up to 4 collections in parallel
2022-02-10T11:57:04.208+0330    building indexes up to 4 collections in parallel
2022-02-10T11:57:04.208+0330    0 document(s) restored successfully. 0 document(s) failed to restore.
2022-02-09T13:50:42.321+0330    preparing collections to restore from
2022-02-09T13:50:42.755+0330    0 document(s) restored successfully. 0 document(s) failed to restore.

我的錯誤是錯誤地設置了--db標誌。當標誌被刪除時,mongorestore恢復數據。使用如下所述的命令。

mongorestore --gzip --archive="./mongo_device.bing.com_20220209-000000.archivegz"

引用自:https://dba.stackexchange.com/questions/307216