Recovering Mongodb collections and documents data - mongodb

good day to you all.
I am currently having a hard time restoring the MongoDB database.
Here is what happened.
Thanks for looking into this matter
Basically, my server and MongoDB 3.2 server running on DigitalOcean.
I made some changes on mongod.conf file to allow remote access from my local machine. Since then, it no longer worked. I got Mongodb connection failed issue so reinstalled new Mongodb version 4.4 and it doesn't want to load existing data which is located in var/lib/MongoDB. So I downloaded the whole data files as posted above on my local machine.
Now, at least I want to open the current database on my local machine but I couldn't find any proper way to achieve this. Thanks again for looking into this issue.

Related

Heroku mlab Add-On deleted after migration to mongoDB atlas

I have a big problem, today I tried migrating my mlab MongoDB sandbox into MongoDB Atlas. I'm using Heroku for my Nightscout instance, this is a cloud based cgm-app for type 1 diabetes patients and it displays my bloodglucose values.
I followed these steps for the migration https://docs.mlab.com/how-to-migrate-to-atlas/#migration-prereqs
I connected my mlab database to my MongoDB project after the Migration the button "connect to mlab" reappeared, it looks like there was no connection established, but I noticed that after I deleted the add-on in heroku, I think that the migration was not correctly done, but I havent got any error message, everything was fine.
I did everything exactly like its written down, now my nightscout site is no longer available and also the database from the deleted mlab MongoDB add-on is lost.
Is there any possibiltie to get my database back. it stored my bg-values over the last 2 years and everything is lost, I haven't made any backup and I'm addicted to that data :(
did you resolve your problem, or was it even one? I migrated today and everything worked fine. Nightscout is working, all old and new values are stored and reportable via Nightscout Reporter.
But in my Mongo Atlas Account I can't access mLab account anymore. It tell's me to disconnect and try reconnect. I'm just not sure if that is an error or just the way it is - as I deleted my only connection to mLab through deleting my MongoDB addon in my Heroku App - I think.
I don't recall ever setting up a real MongoDB account. And the connection during migration was established through opening my own/single MongoDB database (through Heroku Dashboard), which doesn't exist anymore...
I don't think there is any way, to get an already deleted database back. For other people who fear problems like that, you could export your MongoDB database before migration & deletion as binary, json or csv - I tried that to be safe, but couldn't work the commandline properly... I really don't/didn't know what I'm doing there (technical noob) - I'm just glad there are instructions and videos out there and that it worked fine for me.
These are the instructions I should've used (I used different ones when I did it, the following ones are all in all the same, but much clearer & easier):
https://docs.mlab.com/mlab-to-atlas-nightscout-demo-video/
https://docs.mlab.com/how-to-migrate-nightscout-sandbox-heroku-addons-to-atlas/
https://insulinclub.de/index.php?thread/32513-mongodb-shutdown-heroku-nightscout-was-jetzt/

My MongoDB database was lost after running a read-only script

I use MongoDB 4.2 on my local machine (windows 10). I have not changed any configurations, so the default behavior of only accepting local connections should be in place. (I only need to access it locally)
I was running a script that was reading data from my MongoDB, there are no writes to the db in this script. When all the numbers were crunched I noticed weird results, and saw that my database was suddenly gone. I checked my dbpath and the data was gone from there too! Could it be a hack, or was it MongoDB that dropped both the database and the raw data in the dbpath?
I've seen similar questions on this forum, mostly resolved by the author forgetting to reroute to the correct dbpath, which is not the case here. I've checked the log but the log seems to be very limited (I restarted mongod and could only see logging happening after the restart).
MongoDB does not delete all of the files in its data directory.
Most likely either you are checking in the wrong place or something external to MongoDB deleted its files.

Lose data of local MongoDB

My scenario is that I use a local DB and I always keep it running. An hour ago, I upgraded iTerm2 and all opened windows/tabs closed. After I restart iTerm2, I found that mongod is still running, so I use kill $(pidof mongod) and restart with mongod --dbpath ./db. However, most data I inserted has disappeared. I have checked .zsh_history to confirm that I am using the same db folder. I have also checked all mongod.lock address on my computer to see other DB folders, and none of them stores my latest data. I have seen mongo.log and the commands I used to query new data was still there. Therefore, how can I find my lost data? Thanks.
P.S. This situation happened last month when my mac was forced to shut down because of low battery. It happens again so I ask and want to know why it happens and what I can do.

Mongodb 3.0.15 on Ubuntu 14.04 - data disappeared - possible causes?

I have been logging bitcoin order books and trades for the past 20 days in mongodb. 1 database [bitmicro], 1 collection for trades, 1 collection for books.
now suddently all the data is gone and the logger has started from scratch since yesterday.
The mongo log doesnt show any entries since October. And a new database appeared called Warning exactly when the data loss happened
> show dbs
Warning 0.078GB
bitmicro 0.453GB
local 0.078GB
After some reading it might be the case, that the filesize of the collection became too big and ubuntu deleted it?
Since the log /var/log/mongodb/mongod.log doesnt show any entries since starting the server, how can I find out what happened?
the existence of the Warning database implies that your database was accessed by a malicious 3rd party, and your database is exposed to the internet without any authentication.
https://docs.mongodb.com/manual/administration/security-checklist/

migrate the MMAPv1 generated data to WiredTiger

I am running a (keystonejs) webapp using mongodb 3.0 as database. I cloned the webapp and run a second instance using a 3.2 mongodb release (on a generated but yet empty data base). What I need to do now is get the data from the first database to the second. Since mongodb 3.2 uses a different default storage engine which is WiredTiger the clone uses that one. However the original app uses MMAPv1. Is there a easy way to migrate data create by MMAPv1 to WiredTiger?
Create a backup of the database on your old server using mongodump, restore it back to the new one using mongorestore, done. It's covered quite well in the documentation.
https://docs.mongodb.org/manual/tutorial/change-standalone-wiredtiger/
You can create replica set and add new machine to it. Doing so, you'll have latest data on newer server. Once replication is over, switch new machine to primary and shutdown old server if you want. This way you can easily clone your existing data to wiredTiger without loosing data or negatively effecting existing application.