Search code examples
mongodbmongodump

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


Trying to backup my data base. My mongoDB version is: 3.0.12

I am getting this error:

$ 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

Is it because I used slash character in my collection name? How can I fixe that?

Thanks!


Solution

  • As you pointed, the problem is with your collection name. I'd recommend to rename it to something without slashes.

    If you cannot rename it (it's used by other systems) you should use the output option with "-" so it is written to standard output, then redirect it to a file:

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

    Then you can restore it with:

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