Mongodb's "mongodump" command, javascript execution error

JVG picture JVG · Jul 25, 2013 · Viewed 7.8k times · Source

Perhaps I have a complete misunderstanding of how mongodump is supposed to work, but I can't seem to get it to do anything besides returning a JavaScript execution failed: SyntaxError: Unexpected identifier error.

Here's what I'm doing:

  • Mongod is running
  • I want to backup a database called "mydb"
  • I'm inside the mongo shell
  • I tried the command mongodump --db mydb and get the above error
  • I've tried both mongodump and mongoexport, both have the same issue

What am I doing wrong here?

Answer

karthick picture karthick · Jul 25, 2013

Try the following it will work

i.Open the terminal

ii. Enter mongodump --collection collectionname --db dbname (Don't go inside mongo shell);

iii.If default port is different(other than 27017) then go for the following command

   mongodump --host mongodb1.example.net --port 37017 --username user --password pass    --out /opt/backup/mongodump-2011-10-24