Dumping mongodbdatabase using meteor locally - mongodb

I need to know how can dump the mongo db database locally using meteor.The database 'test' resides the folder name 'reaction' is dumping to another folder in same drive.How it is possible?Please help.Thanks in advance

In order to dump the database use the command
mongodump -h 127.0.0.1 --port 3001 -d meteor
After issuing this command a new folder "dump" will be created with your data.

Related

Export all databases with mongoexport

In my app, I'm creating a new database for every user. So I have many databases currently. I need to back up them. But I couldn't find a way to export all databases and collections at the same time with mongoexport
Do anyone have solution?
You can do it using root user and password.
./mongodump --uri="mongodb://rootUser:rootPassword#localhost:27017/?authSource=admin"
This will create a dump folder.
For restoring ensure that your current directory contains that dump folder then.
./mongorestore -h localhost -p 27017 -u rootUser:rootPassword -p rootPassword

How to Backup a Meteor Mongo Database?

To create a backup of my mongo database, I am trying mongodump from my meteor console. The command successfully completes, but creates an empty folder under the dump folder. I use the command
mongodump -h 127.0.0.1 --port 3001 -d meteor
So basically I am trying to backup my database for reactionecommerce. My question is how to backup a meteor mongodb that is running locally? Thanks for any guidance of help.
The issue was with the mongo version 2.6.10. I installed the latest 3.4.4 in my Ubuntu 64 machine following the instructions https://docs.mongodb.com/master/tutorial/install-mongodb-on-ubuntu/ Now I am able to dump the data without any problem.

MongoDB How to move collection from one localhost to another?

I was using MongoDB on localhost of my Ubuntu (just for education purpose), but now, I have a new computer. So, I would like to have this collection on my new PC. What files do I need to copy to do this after installing MongoDB on a new machine ?
Thank you.
First you must read mongo backup and restore this documentation explain how to backup your data base and restore.
Now you should follow this steps :
1> From your old Ubuntu systems takes back up of your DB using following command
mongodump --host DB name --port 27017 --out /path to save your files
this command write data in BSON format, if you want to take only some collections from your DB then use mongodump --collection your collection name --db DB name
2> Now copy all above BSON files to your new PC and use following command to restore your old Ubuntu systems DB.
mongorestore --port <port number> <path to the backup>
before running this command you must install mongoDB.

Copying MongoDB Database into Local Machine

I have a MongoDB database that resides on a remote server machine whose IP address is 192.168.1.20 on a local network. For development and testing purposes, and since I am not allowed to modify or delete the database on the server for security purposes, I want to copy the database on my local machine for my personal use.
Can anyone please tell me, how do I achieve this?
I do this by creating a dump of the remote db to my local machine, which I then restore:
Make sure you have a mongo instance up and running (eg. run mongod.exe from your bin folder in a terminal window. On my windows computer that's C:\mongodb\bin)
Make a dump from remote db: Open a new terminal window, move to the bin folder again, run:
mongodump -h example.host.com --port 21018 -d dbname --username username --password yourpass
(Change the parameters to suit your own situation.)
Restore the dumped database: Once the dump has been made, run the following command so that you have a local db:
mongorestore -d theNameYouWantForYourLocalDB dump\nameOfRemoteDB
(replace nameOfRemoteDB with the name of the remote db, the same as in previous command, and replace theNameYouWantForYourLocalDB with the name that you want your new local db to have)
There is copy database command which I guess should be good fit for your need.
db.copyDatabase("DATABASENAME", "DATABASENAME", "localhost:27018");
Alternatively, you can just stop MongoDb, copy the database files to another server and run an instance of MongoDb there.
EDIT 2020-04-25
Quote from MongoDB documentation
MongoDB 4.0 deprecates the copydb and the clone commands and their mongo shell helpers db.copyDatabase() and db.cloneDatabase().
As alternatives, users can use mongodump and mongorestore (with the mongorestore options --nsFrom and --nsTo) or write a script using the drivers.
Reference here
This should be a comment to the answer of #malla, but I don't have enough reputation to comment so I'm posting it here for other's reference.
In step 2, When you are trying to dump file from a remote server, remember to add out option so that you can restore locally later: (in my first try, I didn't add it and it failed, saying dump\db_name was not found).I'm not sure whether my way efficient or not. But it worked for me.
Step 2:
mongodump -h example.host.com --port 21018 -d dbname --username username --password yourpass --out <path_you_want_to_dump>
Step 3:
mongorestore -d theNameYouWantForYourLocalDB \<path_you_want_to_dump> + nameOfRemoteDB
The mongoexport command:
http://docs.mongodb.org/manual/core/import-export/
Or, mongodump command:
http://docs.mongodb.org/manual/reference/program/mongodump/
mongodb has commandline tools for importing and exporting. Take a look at mongodump --collection collection --db test and mongorestore --collection people --db accounts dump/accounts/
http://docs.mongodb.org/v2.2/reference/mongodump/
http://docs.mongodb.org/v2.2/reference/mongorestore/
this even works over the network
You can use the mongoexport command to copy the database to your local machine.

Copying localhost MongoDB data to meteor servers

So I have been playing around with meteor and mongodb and have a working version set up on my localhost. Unfortunately, when I do meteor deploy xxx.meteor.com it doesn't deploy my database as well.
How do I do this?
Meter deploy only deploys a fresh database. To copy over your data you have to use mongorestore with your local mongodb dump, which you can make with mongodump (docs)
So first dump your database somewhere
mongodump --host localhost:3002
Get your mongodb`s credentials by running (in your project dir):
meteor mongo myapp.meteor.com --url
This will give you your database details in the form:
mongodb://username:password#host:port/databasename
Then you can plug these into mongorestore (docs) and restore your local database over
mongorestore -u username -p password -h host:port -d databasename ~/desktop/location_of_your_mongodb_dump