According to the backup file and oplog restore data to a certain point in time, why can’t the report be restored?

  mongodb, question

1 backup to /var/lib/dumps/图片描述

2 A table was deleted by mistake图片描述

3 backup oplog to /root/dump/ directory图片描述

4 copy /root/dump/local/ to /root/dump/oplog.bson图片描述

5 Find the time point of deletion by mistake through bsondump图片描述

6 according to the found time point to restore to error before deleting by mistake:

[root@cd_spy2 /var/lib/dumps]# /usr/local/mongodb/bin/mongorestore –port 27020 –oplogReplay –oplogLimit 1472547691:1 /var/lib/dumps
connected to:
Tue Aug 30 17:13:35.270 Latest oplog entry on the server is 1472547691:1
Tue Aug 30 17:13:35.270 Only applying oplog entries matching this criteria: { “ts” : { “$gt” : { “$timestamp” : { “t” : 1472547691, “i” : 1 } }, “$lt” : { “$timestamp” : { “t” : 1472547691, “i” : 1 } } } }
Tue Aug 30 17:13:35.271 /var/lib/dumps/admin/system.profile.bson
Tue Aug 30 17:13:35.271 skipping
Tue Aug 30 17:13:35.271 /var/lib/dumps/test/foo.bson
Tue Aug 30 17:13:35.271 ERROR: The oplogLimit option cannot be used if normal databases/collections exist in the dump directory.

The literal meaning is to find the latest oplog first, and then apply the event between the latest oplog and the point designated by my oplogLimit (this example is to do nothing). I don’t understand this, it should be the time from the time when I backup data to the time specified apply oplogLimit.

Then I insert another piece of data into the wrong table in the database, and the latest oplog of the system is even newer than the point specified by my oplogLimit before execution.

[root@cd_spy2 /var/lib/dumps]# /usr/local/mongodb/bin/mongorestore –port 27020 –oplogReplay –oplogLimit 1472547691:1 /var/lib/dumps
connected to:
Tue Aug 30 17:16:08.756 The oplogLimit is not newer than the last oplog entry on the server.

Error reporting: I said that the point designated by oplogLimit has no systematic oplog update (this is not nonsense, I want to restore to the past, of course, is it still possible to restore to the future?-! ! ! ! ! ! ! ! ! ! ! )

According to the error message, you should put the oplog.bson file into an empty directory before restoring to.