Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb's "mongodump" command, javascript execution error

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?

like image 894
JVG Avatar asked Jul 25 '13 05:07

JVG


People also ask

What does Mongodump command do?

mongodump is a utility that creates a binary export of a database's contents. mongodump can export data from: Standalone deployments. Replica sets.

How do I run Mongodump on Windows?

Start Mongo, open a new tab in terminal. First navigate to the folder where you want to save the backup, then type the following command. On Windows, open command prompt in the folder where mongodump.exe resides, after mongod.exe is running, then run the mongodump command and it works.

What is the difference between Mongoexport and Mongodump?

mongoexport is a command-line tool that produces a JSON or CSV export of data stored in a MongoDB instance. mongodump is a utility for creating a binary export of the contents of a database.

How recover data from Mongodump?

The basic way to restore a database is to use the mongorestore command to specify the backup directory (dump directory) without any options. This option is suitable for databases located in the localhost (127.0. 0.1) using the port 27017.


1 Answers

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
like image 95
karthick Avatar answered Oct 09 '22 00:10

karthick