MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Restore oplog Dump into another instance

mongodump --host=“rs0/localhost:27017,localhost:27018,localhost:27019” --readPreference=secondary -d local -c oplog.rs --query “{”$and":[{“o.msg”:{"$ne":“periodic noop”}},{“ns”:“hello.items”}]}"-vvv -o /home/anupama/backupec2/full_back

I used it to dump hello database from replicaset using oplog dump but I want to know how can i restore the hello database in another new instance from dump oplog file using mongorestore is

mongorestore ./backup/inc_back/local/oplog.bson

my bson dump output

{
    "ts":{
       "$timestamp":{
          "t":1585005237,
          "i":1
       }
    },
    "t":{
       "$numberLong":"1"
    },
    "h":{
       "$numberLong":"0"
    },
    "v":{
       "$numberInt":"2"
    },
    "op":"i",
    "ns":"hello.items",
    "ui":{
       "$binary":{
          "base64":"q6+dIqy6TJihZj02fwNm7w==",
          "subType":"04"
       }
    },
    "wall":{
       "$date":{
          "$numberLong":"1585005237006"
       }
    },
    "o":{
       "_id":{
          "$oid":"5e7942b415f1175f7de3440c"
       },
       "name":"Raushan",
       "branch":"cse"
    }
 }

Is this restore of a DB or a collection?

You can use --nsInclude with --db options

The --db option for mongodump specifies the source database to dump.
The --db option for mongorestore specifies the target database to restore into.

I tried but not working even oplog file is not getting changed in other instance.

I am collecting data from oplog.rs. and looking to restore my db hello and collection item from the oplog.

So restore succeeds but you don’t see changes?
Did you try --drop option

--drop ``

Before restoring the collections from the dumped backup, drops the collections from the target database. --drop does not drop collections that are not in the backup.