MongoDB Database Backup
Mongodump--host mongodb.example.net--port 27017
Backup path Selection
Mongodump--out/data/backup/
Select the databases and collections to back up
Mongodump--collection mycollection--db test
Create a non-local database backup
Mongodump--host mongodb1.example.net--port 3017--username user--password "Pass"--out/opt/backup/ Mongodump-2013-10-24
=============================================================================================================== =====================================
Database recovery
Mongorestore--port <port number> <path to the backup>
Mongorestore dump-2013-10-25/
Mongorestore--oplogreplay
Mongorestore--host mongodb1.example.net--port 3017--username user--password ' pass '/opt/backup/mongodump-2013-10-24
Cold backup
Service Mongod Stop
Specify the location of the database file
Cd/backup
Mongodump--dbpath/var/lib/mongo/
Service Mongod Start
Hot backup
# Cd/backup
# mongodump--db mongodevdb--username mongodevdb--password yoursecretpwd
# ls-l dump/
Drwxr-xr-x. 2 root root 4096 Sep 7 10:08 Mongodevdb
Backup a specific Collection
# Cd/backup
# mongodump--collection employee--db mongodevdb--username mongodevdb--password yoursecretpwd
# mongodump--collection employee--db mongodevdb--username mongodevdb--password yoursecretpwd--out/dbbackup
[local-host]# mongodump--host 192.168.1.2--port 37017--db mongodevdb--username mongodevdb--password YourSecretPwd
Service Mongod Stop
Cd/backup
Mongorestore--dbpath/var/lib/mongo Dump
Cd/backup
Mongorestore--dbpath/var/lib/mongo--db Mongodevdb dump/mongodevdb
Drop the old Database before Restoring
# Cd/backup
# mongorestore--dbpath/var/lib/mongo--db mongodevdb dump/mongodevdb
# mongorestore--dbpath/var/lib/mongo--db mongodevdb--drop dump/mongodevdb
Mongorestore--host 192.168.1.2--port 3017--db mongodevdb--username mongodevdb--password yoursecretpwd--drop/backup/ Dump
MongoDB Database backup operation