I am trying to take mongodump of a collections of last 24 hours using bash but getting errors as i am unable to use custom date in query parameter of mongodump statement.
timeInMs=$(expr "$(date +'%s%3N')" - 86400000)
mongodump -u user -p password --authenticationDatabase admin --db dbname -c collection --query '{startTime:{$gte:new Date(${timeInMs})}}'
timeInMs is as expected (time in ms 24 hrs ago) but problem is getting query right. Lots of hit & trial used but no success yet. Have used following :
'{startTime:{$gte:{"$date":"${timeInMs}"}}}'
"{startTime:{$gte:new Date\"(${timeInMs})\"}}"
'{startTime:{$gte:new Date("${timeInMs}")}}'