You have a problem with your nested quotes:
mongodump -d dbname -c coll_name -q "{source: "7e04f65e47ed3ddfeb21716a247e3fa6", timestamp: {\$gte: new Date(2013, 10, 1)}}"
# ----------------------------------^---------^
I'd use single quotes on the outside:
mongodump -d dbname -c coll_name -q '{source: "7e04f65e47ed3ddfeb21716a247e3fa6", timestamp: {$gte: new Date(2013, 10, 1)}}'
That also lets you avoid escaping the $gte
too. And if it doesn't like the new Date
then you could use:
{$gte: new Date(1383264000000)}
For posterity, it seems that the -q
parser doesn't like the three argument form of the Date
constructor nor does it like the ISODate
function that MongoDB usually uses for dates and timestamps. I get confusing assertions failures like:
Assertion: 10340:Failure parsing JSON string near: timestamp
when I try either of those. This is pretty puzzling to me but sometimes it is better to just quietly walk away once a workable solution is found.