How to restore a db in mongoDB - mongodb

i tried to restore a db using mongorestore but i get this error:
2020-09-14T18:48:59.210+0200 error parsing command line options: error parsing positional arguments: provide only one polling interval in seconds and only one MongoDB connection string. Connection strings must begin with mongodb:// or mongodb+srv:// schemes
2020-09-14T18:48:59.258+0200 try 'mongorestore --help' for more information
I tried a lot of combinations, like this:
mongorestore -h localhost -d projectdb C:\Users\leo\Downloads\project\projectdbfiles
But without success.. i read the documentation and i tried to use --host:host and /host:host..
Im using windows

Below solution worked for me
Copy mongorestore.exe to C:\Users\leo\Downloads\project folder
open command prompt C:\Users\leo\Downloads\project\ location
mongoservice.exe projectdbfiles\
it should work.

Related

why mongorestore command don't run?

I insert in the command prompt##
mongorestore --db gescom C:\Users\LENOVO\OneDrive\Bureau\S2\BD noSQL\TP\employes\employes.bson
this is the problem log
2021-03-09T23:02:10.672+0100 error parsing command line options: error parsing positional arguments: provide only one polling interval in seconds and only one MongoDB connection string. Connection strings must begin with mongodb:// or mongodb+srv:// schemes
2021-03-09T23:02:10.718+0100 try 'mongorestore --help' for more information

Mongodump - command not found when executing dump

I'm trying to create a backup of my database using Mongodump. The problem is that every time i execute the dump, i get the following error:
--collection: command not found
Here is the command:
mongodump --uri=MYURI --collection TEST-COL --gzip --out=/var/backups/testbackup
I'm using linux, while on windows the same command seems to work. Any advice?
The URI is a connection string, must be wrap with double quotes ("").
--uri=<connectionString>

Cannot mongodump to a single archive

I'm trying to dump a MongoDB database to an archive. Using the following command as given in documentation.
sudo mongodump --uri=mongodb://username:password#host:27017/dbname?authMechanism=SCRAM-SHA-1&authSource=authdb --archive=file.archive
But it doesn't dump as expected rather it creates a dump folder with .json file for each collection, which should be a single archive file as given.
It also shows the following error -
--archive=file.archive: command not found
Mongo version -
MongoDB shell version v3.6.3
I had this problem & I figured out the reason it was happening.
The command I was running was
sudo /usr/bin/mongodump --uri=mongodb+srv://{username}:{password}#{atlasendpoint}.mongodb.net/?retryWrites=true&w=majority --archive={filename}.archive --gzip 2>&1
I was getting the same error as you. I change the shell command by wrapping quotation marks around the URL; this fixed it for me.
sudo /usr/bin/mongodump --uri="mongodb+srv://{username}:{password}#{atlasendpoint}.mongodb.net/?retryWrites=true&w=majority" --archive={filename}.archive --gzip 2>&1

Error when running mongodump

I have a rollback file, but when I run mongodump on it I get an error:
mongodump.exe .\test.foo.2016-04-27T16-49-54.0.bson > f.json
02:33.521+0100 positional arguments not allowed: [.\test.foo.2016-04-27T16-49-54.0.bson]
02:33.522+0100 try 'mongodump --help' for more information
You just used the wrong command. You have to use the bsondump command instead of the mongodump command. Mongodump is only for create of the backup file. From the parameters you provide in your command I assume that you want to convert the bson file to a human-readable json file.

MongoExport Too many positional options

Am trying to run a mongoexport using a remote connection by filtering on date ranges. A very simple query, however, I am running into positional errors issue. I;ve read through most of the posts regarding it, did the epoch conversion etc. But completely hit a block. Hopefully someone here can figure out what I am doing wrong.
Below is my command and the error message:
C:\ mongoexport --host 1.1.1.111:1111 --db IQ -u user -p password --collection CallLog --out calllog.json --query '{"Call.StartTime":{"$gte":new Date(1411066005000),"$lte": new Date(1406918805000)}}'
Error parsing command line: too many positional options
try 'mongoexport --help' for more information
We use the authenticationDatabase option when connecting and running queries from mongo. Tried the above using that as well. But same error.
What am I doing wrong here?
Thanks so much in advance.
Regards,
Simak
resolved this by interchanging the " and ' marks..Didn't realise that those made all the difference.
Thanks!