I am getting an empty directory after running mongodump - mongodb

I want to do a backup of my MongoDB for a Meteor app on Ubuntu 14.04 on Digitalocean. So I ran the command
mongodump -d dbName -o ~/backups/first_backup
The log i see is this
connected to: 127.0.0.1
Tue Jun 14 09:10:58.240 DATABASE: dbName to /home/kenshinman/backups/first_backup/dbName
Then when I visit the path, I see a blank folder with the dbName.
Am I doing something worng?
But I also found out that the mongoexport command is working fine

I found a solution. Thanks to nearpoint for his solution. Since I uploaded my MeteorJs app with Mupx, MupX placed my mongodb in a container using Docker
So, I followed his steps and It worked fine.
Here's his solution

Related

Parse server - File not found

Parse server version: 2.8.4
Parse dashboard version: 1.2.0
MongoDB version: 4.0.2
Hosting service: DigitalOcean
=================================
I'm transferring my app to a new Parse server and a new MongoDB server.
Everything works fine except the fact that I can't load any images! The content is being fetched properly, but the images don't load. Neither from the app, nor from the dashboard. (I get the File not found. there)
Here's how I transferred my db:
mongodump --host sourceIP -d dbName --port 27017
and then to load it:
mongorestore --db dbName dbDir --username “username” —password "password" --authenticationDatabase "admin"
I did a db.fs.files.find() and the images seem to be there just fine!
I also tried uploading a new image file and got the error:
error 130. Could not store file.
I believe that this is a db-side issue, because I tested the parse server with another MongoDB I have and it was working!
I also tried creating a new droplet and redo everything, but it didn't fix it!
Any suggestions?
I spent 2.5 days of my life, full of stress, just because I had the symbol & in my auth password, inside my databaseURI! For some reason, it doesn't affect fetching the data but it does affect fetching images!

Getting empty folder when using mongodump to back up my MongoDB

Basically, I have a problem with using mongodump to back up my MongoDB.
This is the general syntax I use in SSH:
mongodump -d myDatabaseName -o ~/backups/my_backup
This is the resulting message:
Fri Apr 22 20:39:57.304 DATABASE: myDatabaseName to /root/backups/my_backup/myDatabaseName
This simply generates a blank folder with no files in it whatsoever. The actual database is fairly large, so not sure what's going on.
I would also like to add that my mongodump client and my MongoDB version are both the same (version 2.4.9).
Not sure how to go about fixing this. Any help is appreciated.
This is a similar question as Mongodump getting blank folders
There is no accepted answer as of writing my answer. Here is what I did to resolve my issue and I believe it will help you as well.
The default mongodb-client deb package with Ubuntu is the issue. I removed those and installed the mongodb-org-tools package from mongodb.com https://docs.mongodb.com/master/tutorial/install-mongodb-on-ubuntu/?_ga=2.36209632.1945690590.1499275806-1594815486.1499275806
They have other install instructions for your specific OS if you are not on Ubuntu https://www.mongodb.com/download-center?jmp=nav#community
Try adding the port of mongodb_port as in:
mongodump --port your_number -c the_collection -d the_database
Make sure that you have the exact name of the database. If you spell it wrong, this could happen. To confirm, connect to your mongo database and type show dbs to see a list of database names. Then make sure that your databasename parameter -d <databasename> matches one of those in the list.

Mongorestore command not found with meteor

Ok guys I receive a bunch of files of a mongodb (.bson and .json) I want to replace my current meteor mongodb, I have read al this post about it:
meteor: how can I backup my mongo database
Mongorestore, from meteor production server to local
Restore a mongodb in meteor production server
MongoDB: mongorestore: command not found (this actually have nothing to do with my problem)
and I end writing in my terminal while meteor app was running
mongorestore -h 127.0.0.1:3001 --port 3001 -d meteor ~/Github/mongo/mongoDBRESTORE/admin/
but the problem its that terminal output is not command found
does anybody know what Im doing wrong, what its the right way to do this?
As #rgoomar pointed in the comments I need to download https://www.mongodb.org/downloads the mongodb bin files then I simple execute ~/mongodb/bin/mongorestore -h 127.0.0.1:3001 -db meteor ~/Github/mongo/mongoDBRESTORE/admin
and worked!

Back up meteor database with mongodump?

This post is about backing up your meteor database
I am trying to back up my meteor database and I understand what this post is telling me to do, but I must not be in the right directory when I run the mongodump command, b/c I keep getting 'Command not found'. Or do I need to export a path?
[EDIT]
OK, now I have the binaries installed but when I run 'mongodump', I get:
couldn't connect to [127.0.0.1] couldn't connect to server 127.0.0.1:27017
... and when I run 'mongodump --host localhost:3002', I get:
couldn't connect to [localhost:3002] couldn't connect to server localhost:3002
Now what?
OK, thanks to #David Weldon, I can provide a fairly complete answer to this issue:
Backing up and restoring your local MongoDB for Meteor users (OSX)
Backup:
1) Your app must be running, so start up your Meteor server.
2) In a terminal window (NOT in the meteor mongo shell), enter: mongodump -h 127.0.0.1 --port 3001 -d meteor
This will create a 'dump' directory inside your home folder (your name under Users).
3) If you get a 'command not found' message, you probably just installed Mongo as a part of Meteor, meaning you don't have the mongo command line tools. Use a package like Homebrew to reinstall Mongo and you will have the command line tools. This will also add the correct PATH information to your system, so that it can find the tools.
Restoring:
1) From MiniMongo shell (run ‘meteor mongo’ inside your Meteor project dir), enter:
db.[collectionName].drop(); //repeat for all collections you wish to restore
2) Then, from a terminal window, enter:
mongorestore -h 127.0.0.1 --port 3001 -d meteor dump/meteor
Caveats:
The individual documents will not necessarily be in the same order after they are restored. So you need some way to sort documents that need to be presented in a certain order.
Caveats:
The individual documents will not necessarily be in the same order after they are restored. So you need some way to sort documents that need to be presented in a certain order.
There is a flag for this
mongorestore --maintainInsertionOrder
If you are restoring to a mup'ed meteor app, the command would be:
mongorestore -h 127.0.0.1 --port 3001 -d dump/meteor
If you forgot the name of your app, you can see it by going into the mongo shell and listing all databases.

mongoDB test error

I came to know about mongoDB and looked for test.So I made it install and then for test when I used command mongo on terminal it showed an error like this
MongoDB shell version: 1.8.2
connecting to: test
Sun Jul 31 01:06:07 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:79
exception: connect failed
So can someone tell me what is the problem.I am using ubuntu 11.04.For installation instruction I had used this site.I am newbie to this mongoDB so please helpe me.Any help will be highly appreciable.
All you need to do is open 2 terminal tabs. In one, run
mongod
which starts the MongoDB server.
In the other, run
mongo
which is the shell that connects to your MongoDB server.
It looks like MongoDB isn't running. Can you connect to the web interface in your browser?
http://localhost:28017
Also, do you see the process running on your machine? You should see an entry for mongod when running ...
$ top
or
$ ps aux
why not install mongodb from 10gen's own debian repository? much easier and more likely to work
http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages
To see if mongodb is running, this also helps:
sudo service mongodb status
if it is running, and you still get the same error, then it must be the weird localhost bug that mongodb has. it assumes localhost is 127.0.1.1 for some reason. try
mongo 127.0.1.1
I had the same problem. Just try to create folder c:\data and next c:\data\db