mongodump references wrong db directory - mongodb

I had an install of MongoDB that was using on OSX that was using ~/data/db. I had a crash and re-installed MongoDB using Homebrew and it set up the new db path at ~/usr/local/var/mongodb.
All of my apps are working (default port 27017), but when I try to run mongodump it backs up the db in ~/data/db which is now out of date.
How can I get mongodump to reference the correct db folder?

Related

Restoring a mongo database but mongo shell does not show it

mongodump was used long time ago to create a backup, now in order to restore the database for a Meteor app, this command was used:
ais2> mongorestore C:\Users\AAA\Documents\meteor\apps\dump\dump\
PS C:\Users\empl1\Documents\meteor\apps\ais2> mongorestore C:\Users\AAA\Documents\meteor\apps\dump\dump\
preparing collections to restore from
reading metadata for dbais2.dataTeckAllMatchCol from C:\Users\AAA\Documents\meteor\apps\dump\dump\dbais2\dataTeckAllMatchCol.metadata.json
reading metadata for dbais2.makeModelCol from C:\Users\AAA\Documents\meteor\apps\dump\dump\dbais2\makeModelCol.metadata.json
reading metadata for dbais2.usageCol from C:\Users\AAA\Documents\meteor\apps\dump\dump\dbais2\usageCol.metadata.json
reading metadata for dbais2.vehiclesDetailsCol from C:\Users\AAA\Documents\meteor\apps\dump\dump\dbais2\vehiclesDetailsCol.metadata.json
restoring dbais2.dataTeckAllMatchCol from C:\Users\AAA\Documents\meteor\apps\dump\dump\dbais2\dataTeckAllMatchCol.bson
restoring dbais2.makeModelCol from C:\Users\AAA\Documents\meteor\apps\dump\dump\dbais2\makeModelCol.bson
restoring dbais2.usageCol from C:\Users\AAA\Documents\meteor\apps\dump\dump\dbais2\usageCol.bson
restoring dbais2.vehiclesDetailsCol from C:\Users\AAA\Documents\meteor\apps\dump\dump\dbais2\vehiclesDetailsCol.bson
finished restoring dbais2.dataTeckAllMatchCol (11705 documents, 0 failures)
Since I have a directory "dbais2" with all the database files located in the above path.
In a new shell ais2> meteor mongo opens a mongo shell, but show dbs does not show the "dbais2". How can I use the newly restored database? or it was not restored correctly? if so. how to restore it correctly?
Thanks
When you run mongorestore as is, it will connect to the mongo instance running on port 27017 on your local machine (if any). That's what you would use in production. Since the restore succeeded, it must be that you have such an instance running. In that case, run mongo ais2 to connect to that instance and db.
In development, meteor runs its own mongo instance on port 3001 (assuming you used meteor on the default port 3000). When you run meteor mongo that is the instance your shell will connect to. If you want to restore into that, then rerun your command with the port specified:
mongorestore --port=3001 -d meteor C:\Users\AAA\Documents\meteor\apps\dump\dump\
After that you should see your data in the shell opened by meteor mongo. Note that in this command I'm also overriding the database name, so that the data will be imported into the database used by meteor in development (also called meteor).

mongorestore collections with metoer running on local windows 10

I have a dump folder which was created few year ago using mongodump, and want to use this info with a newly created metor app which is the same as the old meteor app after few packages updates and runs without errors.
I installed the mongodb server on this windows 10, the cmd mongo prints
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
MongoDB server version: 4.2.7
what is the "best" way to use the info with the meteor app.
Can some one please give the overview of how all this things work together and then how to use the old info "including the command mongorestore" with the newly created metoer app?
It has been few years so will need polish my thinking on meteor and mongodb again.
My understanding is mongorestore the backup, then run the mongodb server in a separate cmd window, issue a cmd to connect to the restored database, and somehow tell meteor to use this server. Ok I give up.
Thanks
Meteor comes with a bundled MongoDB in development mode, where the mongodb always runs on the app's port + 1 (app: 3000 = mongo: 3001).
You can simply start your Meteor app and when running open a new console and cd into your project folder, then enter:
mongorestore -h localhost:3001 --db meteor /path/to/dump/

Use mongodb data/db data files for restore

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.

Mongodb connecting to a database with old data when connecting through mongo --host

I have a instance running mongodb. I have used a config file while starting the database using mongod -f mongod.conf. I can connect to this mongodb instance from my application server instance. Recently, due to a software upgrade I had to restart the system. After that, I have been facing the following issue:
When I connect to the mongodb instance using mongo from the database instance(locally), it connects me to the proper database with the latest data. But, when I try to connect it from application server instance using mongo --host "ip_address", it is connecting to the same database but it showing the data which is some days old. I needed to know what the issue is and how will I be able to fetch the latest data which is residing in the database from the application server instance.

Roles missing in mongodb

I am using Docker to add mongodb 2.6.5 to a host that already had 2.4.9 installed and I am sharing the data directory.
When I run the 2.6.5 (in container) I get permission issues apparently due to changes in 2.6:
http://docs.mongodb.org/manual/tutorial/add-user-to-database/
But when I try to add a user with role roleAdminAnyDatabase I get "No role named roleAdminAnyDatabase#admin"
Do I need to migrate the data? What is the best way to do that?
I assume I could start up 2.6.5 with no data files and mongorestore the data from 2.4.9. But, does that mean I cannot run 2.4.9 using that directory anymore?