How to create Backup in MongoDB?

When deploying Mongodb in production, you should have a stratergy for capturing and restoring backups in the case of data loss events. Mongodumo and mongorestore are simple effective tools for backing up and restoring small mongodb deployments.

Mongodump reads data from Mongodb datatbase and creates high-fidelity BSON files which the mongorestore tool can use to populate a mongoDB database. Mongodump only captures the documents in the database.MongoDB Backup methods are :

1)mongoexport
2)mongoimport
3)mongodump
4)mongorestore

mongoexport is a command line tool that produces a JSON or CSV export of data stored in a Mongodb instance.

mongoexport –collection=

Eg:mongoexport –collection=students –db=bi.demo –out=students.json

mongoimport is a command line tool that imports content from a JSON or CSV export created by mongoexport or another third party export tool.

mongoimport

Eg: mongoimport –db=bi.taining –collection=students -file=students.json

Mongodump is a utility for creating a binary export of the contents of the database. Mongodump can export data from either mongod or mongos instances.

mongodump

Ex: mongodump –host=localhost

Mongorestore program loads data from either a binary database dump created by mongodump or the standard input into a mongod or mongos instances

mongorestore

Ex: mongorestore dump/