Guys I am trying to backup a database.
First I connect to the server using a ssh tunel, then I execute the following command:
mongodump -d mydatabase -o ~/myfolder
and I get this message:
connected to: 127.0.0.1 Thu Feb 6 18:00:56 DATABASE: mydatabase to /home/backups/myfolder/myfolder
As you can see, the mongodump is creating a folder inside a folder, but inside this folder I don't have any files, no json, no bson file.
Could someone, explain me how to make a backup on my server using ssh and the move the files to my local machine.
Thanks in advance.
You can either select the Collection name from the drop down or enter it manually in the MongoDB SSH connector. You need your SSH credentials (host, port, username, and password) to pull data from a MongoDB collection through an SSH tunnel.
To create backup of database in MongoDB, you should use mongodump command. This command will dump the entire data of your server into the dump directory.
The Mongodump command dumps a backup of the database into the “. bson” format, and this can be restored by providing the logical statements found in the dump file to the databases. The Mongorestore command is used to restore the dump files created by Mongodump.
this is the command you are looking for. this command will access your server database locally 4321 is a port number which can be any port number in which you run your mongodb server [email protected] and this is your server ip.
ssh -L 4321:localhost:27017 [email protected] -f -N
and after this
mongodump --port 4321
this command will make your mongodb dump.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With