recover collection after db.collection.drop() ?

2,249 views
Skip to first unread message

Sam Lee

unread,
Oct 17, 2013, 12:03:43 PM10/17/13
to mongod...@googlegroups.com
I did the following:

    $ mongo test
    test> db.test.insert({a:1})
    test> db.test.find()
    { "_id" : ObjectId("526007ed87cc3e2b2f508faa"), "a" : 1 }
    test> db.test.drop()

I still see the following files:

    test.ns 
    test.0

which I saved to some location.

How can I recover the dropped collection, test ?
There is no backup.



Jeff Lee

unread,
Oct 17, 2013, 2:02:40 PM10/17/13
to mongod...@googlegroups.com
Sam,

Is this a theoretical question, or are you facing a real issue?

If it's a real issue, under normal circumstances, I would say that the data is unrecoverable, but MongoDB support *might* be able to get something back for you.  You could also try to rebuild the collection using the oplog ( assuming you're using replica sets ).

Otherwise, if you are just planning your DR strategy, you should take a look at the Backup and Recovery docs or MMS Backup.


--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sam Lee

unread,
Oct 17, 2013, 2:28:47 PM10/17/13
to mongod...@googlegroups.com
Thanks Jeff,

This is actually a production issue.
Collections foo and bar from production database foobar are dropped.
I was thinking if I can reply journal from the beginning up until the drop command.

I'll look at oplog.

MongoDB support is a paid service?


Jeff Lee

unread,
Oct 17, 2013, 3:20:22 PM10/17/13
to mongod...@googlegroups.com
Yes, commercial support is a paid service.  There used to be a pay-per-incident option, but I think that may have been dropped.

You could also try opening a private ticket in Jira, the folks at MongoDB have been pretty good in the past about helping people out of sticky situations, but it's not a guarantee that they'll be able to do anything for you in this case.

Good luck.

Hornet

unread,
Oct 17, 2013, 3:27:31 PM10/17/13
to mongod...@googlegroups.com
Just remember, the longer data is being written to disk the less data you can recover. Most FS dont really delete the data, they just mark the blocks as not used in the inodes. so the data prolly is there, but is being over written as needed.

-Erik-
Reply all
Reply to author
Forward
0 new messages