I am a newbie to mongodb. I am trying to take a backup of my database using mongodump. But whenever I use this command I get the below error
Referenceerror: mongodump is not defined
I tried creating a new user with all the roles but still I get the same error. Should I add a specific role to take a backup? Or am I doing something wrong?
'mongodump
' is a command/tool which is included in the 'mongodb-tools
' package. If you don't have this package installed on your machine, it makes sense that it is not defined. The mongodb-tools
also provide several other tools used for importing and exporting DBs (like mongorestore
).
That being said, 'mongodump
' is not a mongo-shell command, you shouldn't be using it in mongo-shell. It's a whole different command that you would be executing just like you execute 'mongod
' or 'mongo
' etc.
Here ar e 2 simple exemples for a full backup using authentication and without
mongodump -h hostname -v -u sys_account -p ys_password --authenticationDatabase admin --out folder_location_for_backup
if no authentication
mongodump -h hostname -v --out folder_location_for_backup
here are the mongorestore commands as well
mongorestore -h hostname -v -u admin_user -p admin_password --authenticationDatabase admin --dir folder_location_where_backup_is_located
if no authentication
mongorestore -h hostname -v --dir folder_location_where_backup_is_located
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