Tutorial using mongodump to backup mongodb database

Posted in Tutorials

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

Let’s use the mongodump.exe command to backup our “firstdb” mongodb database that we had created in the previous tutorial.  As in the previous tutorial, we assume that we created the “firstdb” database in mongolab.  And that the user “firstuser” and password was setup for that database already.  If not, start with the previous tutorial.

In the command prompt navigate to location where mongodb shell is installed.  In our tutorial, it was installed in c:\Program Files\mongodb_2.4.8\

Type the command …

mongodump –host ds0xxxxxx.mongolab.com –port xxxxx –db firstdb –username firstuser –password ******

The host for the database can be determined in mongolab database detail page as shown in previous tutorial.  Same with the port. That is the number after the colon.

creating mongodb user

connection string

After running the command, there will be a “firstdb” folder created within the “dump” folder of the current directory.  Inside the “firstdb” folder is the dump of the firstdb database.

mongodb dump

mongodb dump

Next, you should learn how to restore this database using mongorestore.