Junel
Junel

Reputation: 69

MongoDB Collections Unexpected Deletion/Drop

Our collections in MongoDB were automatically deleted/drop and we are not sure why and how. Our MongoDB is working fine for almost 10 months now, so we are really not sure what happened here.

Is there a collection expiration for MongoDB where it automatically delete the collections and its data? Also, would it be possible to retrieve the data?

Thank you in advance!

Upvotes: 0

Views: 1027

Answers (1)

Alex
Alex

Reputation: 38529

Collections do not 'drop' themselves.
Someone has run db.collection.drop() somewhere, intentionally, or accidentally.

You can set a TTL on the data inside a collection - see here however I don't think that's what has happened here.

The only way of retrieving the data would be from a backup.

Restoring a backup to a secondary database and taking a copy of the collection in question, then importing that back into your main database may be the best approach here.
... You do have backups, right?

Upvotes: 4

Related Questions