MongoDB : How to take export a database using mongo dump

We need to take database backup or have to export specific database in  mongo

This command will export specific databases in mongo and export to home folder /dump

> mongodump –db testDatabase

# to compress in zip file and folder

> mongodump –db testDatabase   –gzip

> cd ~/dump

This command will restore or import specific db

>mongorestore –db testDatabase   –gzip  ~/dump/testDatabase

Note :

There command should be run from command prompt / shell and not from mongo sheel.

Mongo restroe does not update existing collections

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s