I use this cmd to restore mongodb to remote db on mLab
$ ./mongorestore -h ds*****.mlab.com:**** -u <user> -p <pass> -d loc8r
but I got this error
2018-05-01T20:22:18.463+0700 using default 'dump' directory
2018-05-01T20:22:18.463+0700 building a list of collections to restore from dump dir
2018-05-01T20:22:18.464+0700 don't know what to do with subdirectory "dump\Loc8r", skipping...
2018-05-01T20:22:18.464+0700 don't know what to do with subdirectory "dump\admin", skipping...
2018-05-01T20:22:18.464+0700 done
I wonder if I did something wrong? there's no problem when I use the same cmd with the dump folder only contains .bson file
With mongorestore
when attempting to restore a backup dump (originally created using mongodump
utility), the mongorestore
utility needs to have access to the .bson file.
When you took the backup/dump, if the .bson file did not exist in the Root folder (of your Data folder), then you will have to explicitly specify its path. What I mean is:
Say you took a backup/dump in D:\mongo_bkup_dir\
folder and if you do have the .bson
file in the root (where the backup was taken), then just providing the root folder location, e.g.:
mongorestore --port 27017 --db dbName --username usr1 --password P@ssw0rd --authenticationDatabase authDbName --dir D:\mongo_bkup_dir\
However, if you had .bson
file in a sub-folder called myDir (when backup was taken), then use:
mongorestore --port 27017 --db dbName --username usr1 --password P@ssw0rd --authenticationDatabase authDbName --dir D:\mongo_bkup_dir\mybackup1.dmp\myDir
HTH.