18

I have created a mongo dump from a remote server and .bson and .metadata files stored in to a folder.

I want to import this folder into my local mongodb. I am using robomongo as a mongodb client ui.

I got some command which are importing json files one by one but I want import all the files at a time by robomongo or cmd.

James Z
  • 11,838
  • 10
  • 25
  • 41
Sangram Badi
  • 3,594
  • 6
  • 30
  • 59

4 Answers4

36

Try with this:

mongorestore -d db_name dump_folder_path
Ivan Aracki
  • 3,668
  • 8
  • 47
  • 63
Bilash
  • 2,200
  • 3
  • 18
  • 43
  • Hint: I tried to run it from mongo console to no avail. It should be run from system shell. – zwolin Oct 09 '18 at 13:23
6

mongodump is a util for creating a binary export of the database. mongodump is used in conjunction with mongorestore as a backup strategy.

If you wanted to restore your mongodump then you would need to use mongorestore

Or,

You could take an export with mongoexport and then use mongoimport

  • @SangramBadi I’ve updated my answer with the links. Examples and options are all there too –  Feb 08 '18 at 11:39
5

Go to relevant folder where dump is located by terminal

mongorestore --host localhost --port 27017 --db [DB_name_in_mongodb] dump/[DB_name_in_dump]

rehan
  • 439
  • 5
  • 15
1

Sharing steps for ubuntu users:

  1. Open a terminal and go to your Home directory
  2. Create a folder with name dump and add your folder which you want to add.
  3. Write command mongorestore and enter it will restore all your documents.
  4. Open your robomongo and connect with the localhost and refresh.

Your new documents start reflecting now. Enjoy :)

Rahul
  • 2,374
  • 2
  • 22
  • 36