undo remove operation in mongodb

Alon Gutman picture Alon Gutman · Dec 17, 2013 · Viewed 18.1k times · Source

I run by mistake a db.collection_name.remove({condition:'true'}) from console and delete object I didn't plan to delete, can I recover them some how?

I db is on mongohq, if it can helps?

Answer

Mzzl picture Mzzl · Dec 17, 2013

It's too late now, but to prevent this from happening again, you can add a member to your replset with priority 0 and slaveDelay set to an hour or so, so that it will be (at least) an hour behind the primary. This member could serve as an oops-I-probably-shouldn't-have-hit-enter-quite-yet recovery.