How to realize backup of mongodb Database

clipboard.png

the bin directory was not found on the server. How to use the command mongodump-h for database backup. Thank you

Mar.01,2021

if your mongo installation adds the bin directory to the environment variable, you can use whereis mongodump to find out where the command is.
if you have not added the environment variable, you can use the ps-ef | grep mongo command to see how your mongo is started.
if your mongo is started by hand-typing command, then the above command can show your startup command. You will also find the bin directory of mongo.
if your mongo is started in ways such as systemd, you may need to further check the startup script of mongo, such as vim / etc/init.d/mongo , to find its bin directory.
if the above command has only one output, that is, only ps-ef | grep mongo , your mongo is not started at all. You don't have to bother figuring out how to back up data with the mongodump command.

important question: the mongodump command only needs to know the port number and authorization information, and you can also connect to url, using mongo. Why do you have to find its bin directory? Look at the screenshot above. You already have the root account of the system. Don't you know the mongo port number and account password?

Menu