Briefly describe how MongoDB is backed up:
1. Mogodump/mongorestore
These 2 commands mongodb the data into the Bson format and can be recovered when needed.
This approach is also applicable as a small database. But if it's sharding or more than hundreds of G data,
is almost impossible to use. Because of the Bson and the space it occupies.
2. Slave Replication
This is the most suitable and reliable, suitable for the production environment. MongoDB supports master+ multiple slave. So it's convenient to start a slave for backup.
However, it is important to note that if the amount of data is very large, if the new slave, speed and no guarantee, we must adjust the size of the oplogsize, for a 300G database,
Can be tuned to more than 60G. In this way, avoid synchronization to the middle of the occurrence of oplogsize and other exceptions.
3. About incremental Hot backup
For some comrades who are passionate about separate file backups, consider using the "incremental hot" backup as a final barrier.
The practice is to initially temporarily shutdown a slave, and then copy the database files to another directory as the starting point for incremental backups.
Each time the backup, in this directory up a slave, using the –fastsync parameters, synchronization is complete can be tar this directory on it.
A disadvantage of this approach is that if the backup cycle is too long, the space waste will be very large, especially in the case of frequent deletion,
The previous version of 1.6 is currently a bug for the deleted space recycle mechanism. This issue should be resolved at the time of release 1.6.
To reclaim these spaces needs to be repairdatabase, slower, and to clone a new db directly from scratch. (In fact, the process of repair is first clone and then copy back).
To sum up, the most reliable and secure way to backup is to use MongoDB's own synchronous replication mechanism.
The most classic and smallest production environment is:
1 Master + 2 Slaves
The above mentioned is this article about MongoDB Backup way of full content, hope everybody can like.