Translated from http://docs.mongodb.org/manual/core/backups/
There are several ways to back up the MongoDB cluster:
- Backup by copying the underlying data file
- Back up with Mongodump
- Cloud Backup via MMS (Mms:mongodb Management Service)
- Backup software via MMS on Prem backup
1. Backup by copying the underlying data file
If the storage device supports a point-in-time snapshot (snapshot), you can use these snapshots to create a backup of MongoDB. Amazon's EBS storage system, for example, supports EC2 snapshots. LVM Manager is able to generate snapshots on Linux.
If MongoDB is running, to get a proper snapshot, MongoDB must turn on the log function, and the log file and MongoDB data file will be on the same logical volume (logical volume). If the log (journaling) feature is not turned on, the data in the resulting snapshot cannot be guaranteed to be consistent.
For sharding Systems (sharded system), you must turn off balancer and obtain snapshot for each shard and each config server at the same time.
You can also use CP, rsync or other tools to copy files. However, copying multiple files is not an atomic operation, you must stop all writes before copying, otherwise the copied data may be in an inconsistent state.
2. Mongodump
By copying the underlying file does not support point-in-time recovery (point-in-time recovery) of the complex set (replica set), and it is difficult to manage large shard clusters. In addition, these copies are large because they contain indexes and the underlying padding and fragments. and mongodump can generate smaller backups.
The Mongodump tool reads data from the MONGODB database and generates a Bson file. Mongorestore is able to restore this data to the MongoDB database. Mongodump is a very effective tool for small databases and is not ideal for large database systems.
Mongodump and Mongorestore can operate while the Mongod process is running, and can manipulate the underlying data files.
Mongodump does not back up the index file, so you need to rebuild index after recovering the database.
Use Mongodump and Mongorestore for detailed instructions http://docs.mongodb.org/manual/tutorial/backup-with-mongodump/
MongoDB Backup method