Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb - mongodump is not defined

Tags:

mongodb

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?

like image 300
prdtuty Avatar asked Jan 19 '16 11:01

prdtuty


2 Answers

'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.

like image 61
Dev Vrat Singh Avatar answered Oct 05 '22 04:10

Dev Vrat Singh


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
like image 44
Philippe Courtois Avatar answered Oct 05 '22 06:10

Philippe Courtois