Reputation: 308
I am looking to make a new db on my localhost from a mongodbdump file. the file looks like this:
C:\Users\ME\FILEPATH\database\somedata-mongodbdump.tar.gz
How can I use mongo shell commands to "restore" this data to a new db on my local host? I know how to set up a new DB and insert records no problem, but I am not sure how to unload this data into one.
I am not finding anything in my searches or the documentation as to how to straightforwardly do this.
I'd like to get this file into a DB that I can host locally and use as the back end for testing an app.
Upvotes: 0
Views: 3213
Reputation: 308
I was misguided here and the previous answers is incorrect. While it may be pretty beginner stuff for some people, I will answer my own question in case anyone else runs into this:
A .tar.gz
file is effectively a double zipped file. For Mongo, we need a .bson
file. Unzip the file with 7zip or through CMD.
Once you have the BSON in a directory, in CMD (not mongo shell) type:
mongorestore --db 'yourdbname' --collection 'yourcollectionname' C\filepath\filepath\filename.bson
Upvotes: 1
Reputation: 22316
use mongo restore
mongorestore -u 'user' -p 'password -d 'database' -c 'collection' 'path to file'
if you are using a different database for auth then add --authenticationDatabase='db for auth'
Upvotes: 0