Tuesday, October 2, 2018

Mongo - exporting and importing a single database

On Source Machine
-------------------------
mongo
> show dbs
> exit

mongodump -d abc_xyz_development

(Above command will create a dump/abc_xyz_development folder and put all the files inside it. This folder will need to be zipped and sent to whoever wants to import the database)

On Target Machine
-------------------------

Drop existing database
mongo

> show dbs

> use abc_xyz_development;
> db.dropDatabase();
> exit

Restore from Dump folder:
Command:
  mongorestore -d
E.g.
  mongorestore -d abc_xyz_development ~/abc_xyz_development

No comments:

Post a Comment

Followers

Blog Archive