Search code examples
mongodbubuntudatabase-restoremongorestoredatabase

MongoDB Failed: can't create ActualPath object from path dump: stat dump: no such file or directory


I have a bunch of mongo databases that I need to restore. I used mongodump to get the backup directories, which include the collections inside of them. Something like this:

|- mydir
|-- db1
|--- collection1
|--- collections2
|-- db2
|--- collection1
|--- collections2

I cd into mydir and do mongorestore and I get the following error:

2016-07-25T10:41:12.378-0400    using default 'dump' directory
2016-07-25T10:41:12.378-0400    Failed: can't create ActualPath object from path dump: stat dump: no such file or directory

Then I try to restore a specific database like this: mongorestore db2 and get the following errors:

2016-07-25T10:47:04.413-0400    building a list of dbs and collections to restore from db2 dir
2016-07-25T10:47:04.413-0400    don't know what to do with file "db2/collection1.bson", skipping...
2016-07-25T10:47:04.413-0400    don't know what to do with file "db2/collection1.metadata.json", skipping..."db2/collection2.bson", skipping...
2016-07-25T10:47:04.413-0400    don't know what to do with file "db2/collection2.metadata.json", skipping...
2016-07-25T10:47:04.414-0400    done

No matter what I do or what I try, I alternate between these two errors. And it's the same for any of the databases I use.

I tried using the --db flag, the -d parameter, setting the dump path as the third argument (mongorestore --db [db] [dump_path]). Everything I found around Stackoverflow. Nothing.

I'm stuck on this and I have no idea how to proceed.


EDIT

OS: Ubuntu 14.04

Installed MongoDB following this guide:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/


Solution

  • mongorestore with no dump_path positional argument is expecting there to be a folder named dump in your current working directory. If the folder dump does not exist, you will get the "can't create ActualPath..." error.

    So basically if you do not have a folder named dump, you will need to pass that positional argument. So from the parent directory of mydir run:

    mongorestore mydir
    

    If you want to use the --db option you will need to specify the dump path all the way down to the directory that contains the .bson files for that database or a specific .bson file.

    So for example to restore all collections for db1:

    mongorestore --db db1 ./db1
    

    Or to just restore collection1:

    mongorestore --db db1 ./db1/collection1.bson