Using bsondump tool to view mongodump output in human readable form
In this recipe, we will be using bsondump
tool to examine the BSON files created by mongodump
utility.
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, for instructions on how to import sample data into a MongoDB instance.
How to do it...
- Take a backup of the
mockdata
collection:
mongodump --gzip -d mydb -c mockdata --out /backups/dump
- This should give the following output:
2017-10-04T12:50:37.000+0000 writing mydb.mockdata 2017-10-04T12:50:37.737+0000 done dumping mydb.mockdata (100000 documents)
- Examine the backup directory:
ls -al dump/mydb/
- This should give the following output:
-rw-r--r-- 1 root root 2836312 Oct 4 12:50 mockdata.bson.gz -rw-r--r-- 1 root root 100 Oct 4 12:50 mockdata.metadata.json.gz
- Execute the
bsondump
utility to view the contents of the BSON file:
zcat /backups/dump/mydb/mockdata...