Facing issue while trying for incremental backup using oplog

Hi All,

I am trying to take and incremental backup using oplog.
Below is the query which I am using.


mongodump --host localhost --port 27017 -d test1 -c oplog.rs --query="{“ts”:{"$gte":“Timestamp(1617103955,1)”}}" --authenticationDatabase admin


2021-04-01T09:50:22.206+0100 Failed: error counting test1.: Invalid namespace specified ‘test1.’

mongodump help suggests
/d, /db: database to use
I am using -d test1 which is one of the dbs created by me.

Please suggest how this can be resolved.


Welcome to the community!

Does the collection exist under test1 DB?

Thank you!

yes it has a collecion

Hi @surbhi_kapoor

It looks like your command string is incorrect in terms of its syntax if you wish to use mongodump to perform a point-in-time dump of the database. The specific flag required to dump the oplog is --oplog (see this docs page for the specifics and an example - https://docs.mongodb.com/database-tools/mongodump/#std-option-mongodump.--oplog). This creates a point-in-time backup with any operations to the oplog captured whilst the mongodump is being conducted saved to a file oplog.bson.

If you want to explicitly take a point-in-time of the oplog collection itself, this is not recommended and instead, we have explicitly designed Change Streams (https://docs.mongodb.com/manual/changeStreams/) to deal with scenarios where it was previously necessary to tail the oplog.

My suggestion is to review Change Streams as this is a much easier and scalable solution for a wide variety of uses including incremental backup depending on what you want to achieve.

Hope this helps.

Kindest regards,

1 Like

Thank you @Eoin_Brazil I will have a look.

Hi @surbhi_kapoor

Did this provide a solution for you?

Kindest regards,