I'm trying to dump oplog.rs
from local database, based on timestamp
.
Query directly from mongo shell works but not from mongodump
Query from mongo shell
RS1:PRIMARY> db.oplog.rs.find({"ts" : {$gt : Timestamp(1591199252, 0)}})
{ "ts" : Timestamp(1591199252, 1), "t" : NumberLong(2), "h" : NumberLong(0), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2020-06-03T15:47:32.975Z"), "o" : { "msg" : "periodic noop" } }
...
Mongodump ends either with an error
or with 0 dumped documents
(depending on single quotes for timestamp value) :
1. Output with error
$ mongodump $credentials -d local -c oplog.rs --query '{"ts": {"$gt": Timestamp(1591199252, 0)}}' --out ~/test/
2020-06-11T16:54:36.317+0200 Failed: error parsing query as Extended JSON: invalid JSON input. Position: 15. Character: T
2. Output with 0 dumped documents
$ mongodump $credentials -d local -c oplog.rs --query '{"ts": {"$gt": "Timestamp(1591199252, 0)"}}' --out ~/test/
2020-06-11T16:59:28.264+0200 writing local.oplog.rs to
2020-06-11T16:59:30.232+0200 done dumping local.oplog.rs (0 documents)