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:
mongodump --db mydb
and get the above errormongodump
and mongoexport
, both have the same issueWhat am I doing wrong here?
mongodump is a utility that creates a binary export of a database's contents. mongodump can export data from: Standalone deployments. Replica sets.
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.
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.
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.
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
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