Use mongodb data/db data files for restore - mongodb

Our server is down and have no backups on our dbs. But we were able to get data/db using WinSCP. It would be fortunate if we could use these data files to restore our dbs. I have tried setup mongodb in other server and copied data/db from failed server. As I started mongod instance in the new server it says a compatibility issue with authentication schema that data files from data/db was. So we cannot start mongod. I wonder if there's a work around so we can start a mongod with the old data/db from failed server? Or other way to restore dbs? Thank you very much.

Related

MongoDB restore from file backup

I have a backup of /data/db that contains all .wt files along with journal directory etc. I have stopped the db, replaced the current db directory with the one backed up and started the db. This works, Mongo starts up but when I "show databases" there are no results. The local machine (that was backed up) did not have authentication enabled. The machine I am using to attempt the restore does have it enabled, I am able to start the mongo client without any authentication.
Is there another step to this process?
Is the authentication difference an issue?

Restoring MongoDB using only .wt files

My PC crashed. Can I use the .wt files to get my data back?
.wt files from the old MongoDB
You can restore your .wt WiredTiger files downloaded from your Atlas Backup (which unzips or untar as a restore folder) to your local MongoDB.
First, make a backup of your /data/db path. Call it /data_20200407/db. Second, copy paste all the .wt files from your Atlas Backup restore folder into your local /data/db path. Restart your Ubuntu or MongoDB server. Start your Mongo shell and you should have those restored files there.
Keep your wt files at location C:\data\db also check permissions
Go to bin folder of mongodb and hit following command
mongod --dbpath "C:\data\db"
Go to same bin folder and hit mongo command there
I suggest to use noSQLBooster to view db and collections.
make sure you have C:\Programfiles\mongodb\server\4.4\bin\ path set in Environment variables
I restored my db with some BSON files and then I repaired it so it can sync up my db and get my most recent files. I used Robo3T to repair my DB and it worked

Delete or drop Mongodb database on server ecs2 through another server shell file

I am on Linux Server. My MongoDB Database is stored there. Now if I want to delete the database from another machine lets say my development machine, then for that I created the steps but not working for me.
create a delete.sh file
#!usr/bin/env mongo
#instance Ip assume:
mongo 12.122.12.12:27017/tempDatabase --eval "db.dropDatabase"
But I am unable to delete the Database. Any idea that where I have done mistakes. Any interaction is really appreciated

mongodb is not start after restoring /var/lib/mongodb manually

Our server's raid failed today. Right now we have a zip file of mongodbPath but after we extract it, we can not start mongo db again.
I will appreciate any help.
After a lot of searches and contacting with MongoDB's support we fond out that we rsync MongoDB directory when it was writing.
So we cannot restore data and we had data lost!
If you want to use rsync for getting backup of MongoDB you should stop it.
This may help.

MongoDB data not stored in /data/db, although it is saving data... but where?

I'm completely new to MongoDB - I've installed all the programs and set it up so that I run mongod.exe and then mongo.exe. I created a new database called 'test' and inserted some data. However, I can't see any files being created in the /data/db directory. The data is definitely being stored somewhere, and when I closed down all the cmd boxes and started the processes again, the data I initially pushed onto the DB is still there.
I tried running the command 'db.adminCommand("getCmdLineOpts")' which apparently should show my DB Path, but it doesn't:
Can anyone offer some insight on this? Thanks :)
For using mongod.exe without parameters default is C:\data\db. Check start up parameters if you run server as service.
You can run this command to retrieve the dbpath if you in a Linux environment:
grep dbpath /etc/mongod.conf
db.adminCommand("getCmdLineOpts") is not running the db path as it was not specified a a command line parameter when the mongod process was started. It seems the db path is configured in the mongod.conf configuration file and the above command should return it.