7

mongo client v 4.4

mongorestore --host <host> --port 10255 -u <user> -p <password> --db <db_name> --collection structures structures.bson --ssl --sslAllowInvalidCertificates

2020-10-03T23:13:44.440+0300    Failed: <db_name>.structures: error restoring from structures.bson: (BadValue) Retryable writes are not supported. Please disable retryable writes by specifying "retrywrites=false" in the connection string or an equivalent driver specific config.

I tried the other way

mongorestore "mongodb://<host>:<password>@<name>:10255/?ssl=true&retrywrites=false&appName=@name@" dump/

with the same error.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
Nedudi
  • 5,639
  • 2
  • 42
  • 37
  • Does this answer your question? [Importing BSON to CosmosDB MongoDB API using mongorestore](https://stackoverflow.com/questions/63900885/importing-bson-to-cosmosdb-mongodb-api-using-mongorestore) – D. SM Oct 04 '20 at 15:07

1 Answers1

26

I found that this command --writeConcern="{w:0}" can solve the "rewrite=false" error. I have tried it and here's my command.

mongorestore.exe --uri "<cosmosdb_connect_string>" --db Database1 --collection collection1 --ssl --sslAllowInvalidCertificates edx-dump/Database1/collection1.bson --writeConcern {w:0}

enter image description here

Tiny Wang
  • 10,423
  • 1
  • 11
  • 29
  • If you are getting the same error as I am, this should be the accepted answer. – juliano.net Jul 20 '21 at 18:05
  • This! If you run into this error specifically when attempting the mongorestore command on a Azure CosmosDB (Mongo API) instance, adding this command resolves the issue. – BenW301 Aug 05 '21 at 13:51
  • I had the same issue and this resolved it. You can also see in the CosmosDB docs that this comment is being shown in an example: https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/tutorial-mongotools-cosmos-db – Lukaesch May 11 '22 at 09:18