Mongodb keeps dropping all my collections randomly - mongodb

For the last week and a half for some reason my Mongodb collections all get dumped. I can't find a reason why this is happening there doesn't seem to be a real pattern to when/why the collections get dumped. Does anyone have any insight? I'm running Mongodb version 2.6.12.

you can read this artical https://snyk.io/blog/mongodb-hack-and-secure-defaults/
also you can have a look on MongoDB database deleted automatically it should solve your problem.

Related

How to detect mongo documents with duplicate field names

I discovered one of my mongodb documents has duplicate fields with the same key.
I also realize this is supported by mongoDB (as per MongoDB Documentation)
I'm wondering if anyone knows how to properly query to diagnose the scope of such an issue.
And if anyone has any insight into possible root causes when working in Javascript that'd be nice too.

Collections are deleted by themselves in MongoDB

I have a problem with MongoDB when I try to create a collection. That is, I create it and then i check it with the commands:
db.mycollection.find()
or
db.mycollection.count()
And the data comes out, however, after a certain time (minutes), the data of the collections are eliminated by themselves, that is to say they are not persisted, what is happening?
Thanks.

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!
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?

Document delete in MongoDB instance

We've been facing issues where quite a lot of documents are getting deleted from our mongodb instance. I've confirmed that it doesnt happen because of our code since we only have the find and replaceOne(with crupdate:true) API's used.
I ran the command db.serverStatus and under the opcounters section i can see that there are 1929 deletes. The mongodb.log doesn't give much information and i dont see anything related to deletion of documents.
Right now ours is a single node mongodb instance and so i think the opLog is not enabled, which would have probably helped in knowing when the deletes took place.
Is there any other way to debug this or is there anything specific in the mongodb.log i should be looking for?

MongoDB & Mongoose: How to find and remove a large group of documents. findAndModify(..... {remove:true})?

Bear with me as I'm pretty new to MongoDB and mongoose has been my only interaction with it. So apologize ahead of time if I'm not properly separating the two technologies or understanding either.
I have a collection that is basically a log. Each log item is the result of a status check on a specific server that I have in my system. When I delete a server I'd like to also remove all the associated log entries. Whats the most efficient way to do this? I know I can find all the log items with a specific server id then iterate through each and remove it but that seems really inefficient. I've read through most of the mongo documentation and it looks like findAndModify is the best way to do this but I can't figure out syntax for this with mongoose. Any chance someone could help me out?
I'm using the latest version on mongoose at the moment, 1.7.2
Maybe I'm missing something here, but why not just do
db.logs.remove({serverid: deletedServerId})
?