Rehan Khatib
Rehan Khatib

Reputation: 1

How to convert date from Linux to MongoDB timestamp and mongodump

I want to convert linux date into mongodb timestamp

TODAY= date '+%Y-%m-%d%H:%M:%S' into this $date:"2023-04-09T16:27:54.282Z"

So I can use same date in my dump query

First I want to get yesterday date (todays date minus one day)

TODAY= date '+%Y-%m-%d%H:%M:%S'

YESTERDAY= date +'%Y-%m-%d%H:%M:%S' - 3600 * 1000 * 24

till here I am getting results

Next I want to get YESTERDAY date to be converted into mongodb timestamp, it should be display like below..

$date:"2023-04-09T16:27:54.282Z"

So I can use same date in my dump query

mongodump --host "dba_rs/mongoexample.net:27018"  -u root -p **** --authenticationDatabase admin -d local -c oplog.rs   --query='{"wall":{"$gte":{"$date":"2023-04-10T16:27:54.000Z"} }}' --out /mongologs

Upvotes: 0

Views: 45

Answers (0)

Related Questions