how to export whole mongodb database code example

Example 1: mongodb export entire database

// EXPORT
mongodump -d <database_name> -o <directory_backup>
// IMPORT
mongorestore -d <database_name> <directory_backup>

Example 2: mongodb export

mongodump -h <127.0.0.1>:<27017> -d <db> -u <user> -p <pw> -o ./
mongorestore ./

Example 3: any application to export mongodb database from server

$ mongoexport
Export MongoDB data to CSV, TSV or JSON files.

options:
  -h [ --host ] arg         mongo host to connect to ( <set name>/s1,s2 for 
  -u [ --username ] arg     username
  -p [ --password ] arg     password
  -d [ --db ] arg           database to use
  -c [ --collection ] arg   collection to use (some commands)
  -q [ --query ] arg        query filter, as a JSON string
  -o [ --out ] arg          output file; if not specified, stdout is used