I was trying to take backup using oplog based on ts using below code
import pymongo
import traceback
from pymongo.cursor import CursorType
c = pymongo.MongoClient('mongodb://localhost:28001')
oplog = c.local.oplog.rs
first = next(oplog.find().sort('$natural', pymongo.DESCENDING).limit(-1))
ts = first['ts']
while True:
cursor = oplog.find({'ts': {'$gt': ts}}, cursor_type=CursorType.TAILABLE_AWAIT, oplog_replay=True)
while cursor.alive:
for doc in cursor:
ts = doc['ts']
print doc['ns']
db,collection=str.split(str(doc['ns']),'.',1)
It is working well when we have less opLog size but as i am using it on production where oplog size is 48 GB around it is not working.
I cannot alter oplog size.Please suggest some way to take incremental backup.