• 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.

Categorized in: