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



正在尝试备份我的数据库。我的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

是因为我在集合名称中使用了斜杠字符吗?我该如何解决这个问题?

谢谢!

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

如果您无法重命名它(它被其他系统使用(,则应使用带有"-"的输出选项,以便将其写入标准输出,然后将其重定向到文件:

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

然后,您可以使用以下命令还原它:

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

最新更新