General backup strategy for MongoDB
1 Cold Backup--Copy database files
2 Mongodump/mongorestore
Besides Mongodump/mongorestore, there's a couple of mongoexport/mongoimport.
Difference:
Mongoexport/mongoimport Import/Export is in JSON format, and Mongodump/mongorestore Import/export is Bson format.
JSON is readable but bulky, and Bson is a binary file, small in size but hardly readable for humans.
Bson format is Mongodump/mongorestore cross-version may fail, JSON format is mongoexport/mongoimport can operate across versions
The JSON format retains only part of the data, and does not retain other basic information such as indexes, accounts, and so on.
Mongodump Backup Options--oplog
Note that this is dedicated to replica set or Master/slave mode, and the--oplog option is only valid for full-library export, so you cannot specify the-D option. Because the entire instance of the change operation will be concentrated in the local library in the Oplog.rs collection.
The actual effect is to generate a Oplog.bson file at the same time as the export, storing all the oplog between the dump and dump end you start
In replica set, Oplog is a set of capped collection, the default size of which is 5% of the disk space (which can be modified by the--OPLOGSIZEMB parameter), which is located in the db.oplog.rs of the local library.
It records all changes (insert/update/DELETE) operations of the database over time for the entire Mongod instance. Automatically overwrites oldest records when space runs out of time
Its coverage is called the Oplog time window. It is important to note that because Oplog is a set of constant capacity, the range of time windows can cover varies depending on the number of updates in your unit time.
Simply put, the backup will produce two files: database files and Oplog.bson files, the database file holds the data of the backup beginning to a certain time in the end time period,
The Oplog.bson file stores the time the dump started and the system changes the record to Oplog.bson
Recover data files before recovering data in Oplog.bson
General backup strategy for MongoDB