Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does “too many positional options” mean when doing a mongorestore?

Tags:

mongodb

I downloaded a mongodb dump. Now i am trying to move files from the dump to my mongodb location. I'm using mongorestore --dbpath [mongodb path] [dump path] cmd to do this. But i am seeing the too many positional options error in the command prompt. Can anyone help me with this issue.

This is the error from the command line:

C:\Documents and Settings\>mongorestore -dbpath C:\Program Files\Mon
goDb\data\db C:\Documents and Settings\My Documents\localadventure
s\localadventures
ERROR: too many positional options

Import BSON files into MongoDB.

I tried again today and saw the following message in my cmd prompt:

C:\>mongorestore --dbpath "C:\Program Files\MongoDb\data\db" "C:\Documents and S
ettings\seemanapallik\My Documents\localadventures\localadventures"
Mon Dec 23 09:05:01.515 [tools] C:\Documents and Settings\seemanapallik\My Docum
ents\localadventures\localadventures\adventure.bson
Mon Dec 23 09:05:01.515 [tools]         going into namespace [localadventures.ad
venture]
Mon Dec 23 09:05:01.531 [tools] warning: Restoring to localadventures.adventure
without dropping. Restored data will be inserted without raising errors; check y
our server log
1 objects found
Mon Dec 23 09:05:01.546 [tools]         Creating index: { key: { _id: 1 }, ns: "
localadventures.adventure", name: "_id_" }
Mon Dec 23 09:05:01.546 [tools] C:\Documents and Settings\seemanapallik\My Docum
ents\localadventures\localadventures\patch_version.bson
Mon Dec 23 09:05:01.546 [tools]         going into namespace [localadventures.pa
tch_version]
Mon Dec 23 09:05:01.546 [tools] warning: Restoring to localadventures.patch_vers
ion without dropping. Restored data will be inserted without raising errors; che
ck your server log
2 objects found
Mon Dec 23 09:05:01.562 [tools]         Creating index: { key: { _id: 1 }, ns: "
localadventures.patch_version", name: "_id_" }
Mon Dec 23 09:05:01.562 [tools] C:\Documents and Settings\seemanapallik\My Docum
ents\localadventures\localadventures\PaxHeader\adventure.bson
Mon Dec 23 09:05:01.562 [tools]         going into namespace [PaxHeader.adventur
e]
assertion: 16619 code FailedToParse: FailedToParse: Expecting '{': offset:0
Mon Dec 23 09:05:01.578 dbexit:
Mon Dec 23 09:05:01.578 [tools] shutdown: going to close listening sockets...
Mon Dec 23 09:05:01.578 [tools] shutdown: going to flush diaglog...
Mon Dec 23 09:05:01.578 [tools] shutdown: going to close sockets...
Mon Dec 23 09:05:01.578 [tools] shutdown: waiting for fs preallocator...
Mon Dec 23 09:05:01.578 [tools] shutdown: closing all files...
Mon Dec 23 09:05:01.609 [tools] closeAllFiles() finished
Mon Dec 23 09:05:01.609 [tools] shutdown: removing fs lock...
Mon Dec 23 09:05:01.609 dbexit: really exiting now
like image 849
Newbee Avatar asked Dec 21 '13 02:12

Newbee


4 Answers

C:\Documents and Settings>mongorestore -dbpath C:\Program Files\MongoDb\data\db C:\Documents and Settings\My Documents\localadventures\localadventures ERROR: too many positional options

If you have filenames or directory paths containing spaces, these need to be enclosed in double quotes. Otherwise command line programs such as mongorestore may reasonably expect that a space character is the start of a new parameter rather than a continuation of the previous value.

Tip: If you use TAB to autocomplete filenames in the Windows cmd.exe shell the correct quoting should be added automatically.

Assuming that C:\Documents and Settings\My Documents\localadventures\ contains your mongodump files, the expectedmongorestore usage would be:

> mongorestore "C:\Documents and Settings\My Documents\localadventures\localadventures"

Alternatively, you can also change to the dump directory first to save a bit of typing/quoting. A relative path works just fine:

> cd "C:\Documents and Settings\My Documents\localadventures\"
> mongorestore localadventures

You should only include the --dbpath parameter if you are restoring directly to data files and not into a running MongoDB server instance.

There are some more examples of mongorestore usage in the MongoDB manual.

like image 198
Stennie Avatar answered Oct 23 '22 08:10

Stennie


Forewarning to others! I encountered a similar issue that was caused by saving commands in TextEdit and then just copying and pasting. TE must have been affecting spaces and dashes.

like image 7
Gideon Rosenthal Avatar answered Oct 23 '22 08:10

Gideon Rosenthal


In my case, I use

mongorestore --db [dbname] [dumppath]

and it works.

like image 2
holydragon Avatar answered Oct 23 '22 08:10

holydragon


My issue was no setting flags with double hyphens. Instead of setting the db like this --d dbname, I did this -d dbname. Oops!

like image 1
sesamechicken Avatar answered Oct 23 '22 07:10

sesamechicken