26

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
  • 12,209
  • 10
  • 24
  • 44
Sangram Badi
  • 4,054
  • 9
  • 45
  • 78

5 Answers5

51

Try with this:

mongorestore -d db_name dump_folder_path
Ivan Aracki
  • 4,861
  • 11
  • 59
  • 73
Md Nazmul Hossain
  • 2,768
  • 5
  • 26
  • 49
  • 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
  • If you don't have Mongo DB Tools then it will not work on the system shell so install it first then try – Rabby Jun 17 '22 at 07:01
7

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
6

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
  • 469
  • 1
  • 7
  • 17
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
  • 3,293
  • 2
  • 31
  • 43
1
  • Install database tools in local computer
  • restart your command prompt
  • copy C:\Program Files\MongoDB\Tools\100\bin> location and open this in CMD
  • run mongorestore --db dbname complete_folder_location
  • open mongoDB compass, refresh
  • Done
Abhi
  • 305
  • 5
  • 23