I have lots of bson files in the following path:
c:/mongodb/bin/dump/Sid
If I run the command:
> mongorestore --db Sid --drop dump/Sid
I get the following error:
Mon Mar 26 14:36:36 SyntaxError: missing ; before statement (shell):1
What is the problem with my command?
mongorestore is a simple utility that is used to restore backups. It can load data from either: A database dump file created by the mongodump command. The standard input to a mongod or mongos instance.
The mongodump and mongorestore utilities work with BSON data dumps, and are useful for creating backups of small deployments. For resilient and non-disruptive backups, use a file system or block-level disk snapshot function, such as the methods described in the MongoDB Backup Methods document.
In order to restore a MongoDB database, we need to use mongorestore, a command line utility for restoring a MongoDB database. We can use the following C# . NET method and the appsettings. json file from above to get it done.
The Mongorestore command is used to restore a Database by specifying the backup directory (dump directory) without any parameters. This option is appropriate for Databases on localhost (127.0. 0.1) that use port 27017.
From your input, it appears as though you are attempting to run mongorestore from inside the JS shell.
Mongorestore is a standalone application, and is run directly from the terminal.
The following will not work:
c:\mongodb-win32-x86_64-2012-03-20\bin>mongo.exe
MongoDB shell version: 2.1.1-pre-
connecting to: test
> mongorestore --db test --drop \dump\test
Mon Mar 26 11:29:13 SyntaxError: missing ; before statement (shell):1
>
If you run mongorestore directly from the terminal you should be successful:
c:\mongodb-win32-x86_64-2012-03-20\bin>mongorestore --db test --drop \dump\test
connected to: 127.0.0.1
... (truncated for brevity) ...
c:\mongodb-win32-x86_64-2012-03-20\bin>
The documentation on Mongodump / mongorestore may be found in the "Import Export Tools" documentation: http://www.mongodb.org/display/DOCS/Import+Export+Tools
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