mongodump 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: take db backup mongodb

mongodump --out=/data/backup/

Example 3: mongodump

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

Example 4: take db backup mongodb

mongodump --host=mongodb1.example.net --port=3017 --username=user --password="pass" --out=/opt/backup/mongodump-2013-10-24

Tags:

Go Example