I hope you can help me.
It is a question that was asked before, but I have tried all solutions, and simply cannot get it right.
I have spend quite some time researching before posting this question. I have looked at the official MongoDB documents and many other blogs.
How can I make a DB backup/dump remotely, as well as restore that dump locally?
This is what I have thus far:
Running this from a new CMD prompt shell:
C:\Users\Admin>mongodump --host 10.13.9.210 -d C:\Program Files\MongoDB\Server\3.0\bin --port 29039 --out /backup/mongodump-2015-11-13
I get this error:
2015-11-13T10:26:41.371+0200 error parsing command line options: expected argument for flag `/o, /out', but got option `/backup/mongodump-2015-11-13'
2015-11-13T10:26:41.371+0200 try 'mongodump --help' for more information
Secondly, how will I be able to restore this backup locally?
Best Answer
On Linux and Mac, arguments for command-line tools normally have one of these two formats:
--option1 value1
or-o value1
.On Windows, the standard is different:
/option1 value1
or/o value1
.mongo
,mongodump
and other command-line MongoDB programs actually preserve the Linux way of passing arguments. But the Windowscmd.exe
shell will still recognize the character/
as a beginning of a command-line option.Also, in UNIX systems,
/
is used to separated parts of a file system path, e.g./data/db
. On Windows,\
is used instead:C:\Data\DB
.Your problem is this part of the command:
--out /backup/mongodump-2015-11-13
. You kept the backup path in the UNIX format, and/
was recognized as a starting character of a command-line option.You should specify a real file system path on your hard drive instead. For example:
Also, your data path (
C:\Program Files\MongoDB\Server\3.0\bin
) contains a space. Because of the space,cmd.exe
will treatC:\Program
andFiles\MongoDB\Server\3.0\bin
as separate parameters. To prevent this, surround the path with quotes:And as a final note, do not use the
bin
folder to store your data files (as you seem to be doing judging by the path you're passing to-d
).