Taking backup using mongodump tool
In this recipe, we will be looking at how to take MongoDB backups using mongodump
utility. This utility is a part of the MongoDB binary package and is usually available in the bin
directory of the binary package. If you have installed MongoDB using a package management tool, like Ubuntu's apt
or Red Hats yum
, then the utility can simply be invoked by typing mongodump
in the console.
Getting ready
You need a single node MongoDB installation, preferably with some data in it. Refer to the recipe Creating an index in Chapter 2, Understanding and Managing Indexes, to learn how to import sample data into a MongoDB instance.
How to do it...
- Create a directory to store the backups:
mkdir /backups/
- Switch to the directory and execute the
mongodump
utility:
cd /backups/
- Execute the command:
mongodump
- Your output should be similar to this:
2017-10-04T03:26:34.251+0000 writing mydb.mockdata 2017-10-04T03:26:34.459+0000 done dumping mydb.mockdata (100000 documents)
- Examine the...