mongodump 失败:创建 bson 文件时出错,没有这样的文件或目录

mongodump fail: error creating bson file, no such file or directory

正在尝试备份我的数据库。 我的 mongoDB 版本是:3.0.12

我收到这个错误:

$ mongodump  --out .
    2017-05-19T09:45:29.536+0000    Failed: error creating bson file `city/address_/house_sensors:power_sensors.bson`: open city/address_/house_sensors:power_sensors.bson: no such file or directory

是否因为我在 collection 名称中使用了斜杠字符? 我该如何解决?

谢谢!

如您所指,问题出在您的 collection 名称上。我建议将其重命名为不带斜杠的名称。

如果您不能重命名它(它被其他系统使用),您应该使用带“-”的输出选项,以便将其写入标准输出,然后将其重定向到文件:

mongodump -d yourDB -c "your/colName" --out "-" --quiet > col.bson

然后您可以使用以下方法恢复它:

mongorestore -d yourDB -c "your/colName" col.bson