How to Back up and restore MongoDB Database ?

  • The mongo shell does not include functions for importing, exporting, restore or backup.
  • MongoDB has created methods for accomplishing this, so that no scripting work or complex GUIs are needed.
  • Several utility scripts are used to get data in or out of the database in bulk.
  • These utility scripts are used to back up and restore data in MongoDB:

Mongoimport :

  • In MongoDB, it provides a special tool that is used to import data.

Syntax :
mongoimport-jsonarray-db database_name-collection collection_name-file file_location

Mongoexport :

  • In MongoDB it allows you to export its data into other file formats like JSON or CSV.

mongoexport-db database_name-collection collection_name-outpath_or_name_of_the_file

Mongodump :

  • In MongoDB it is used creating a binary export of the contents and export data from either mongod or mongos

Mongorestore :

  • This program loads data from either a binary database dump created by mongodump or the standard input into a mongod or mongos instance.
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

MongoDB Vs CouchDB

                MongoDB                  CouchDB It Provides faster read speeds. If read speed is critical to your database, MongoDB is faster than CouchDB. No mobile support provided. It can be run…
View Answer

What are the Features of MongoDB ?

It has so many great features while being a NoSQL database. It is unique and attractive. They are making MongoDB widely usable and popular. Features of MongoDB: Schema-less Database Replication…
View Answer