'mongorestore file X does not have .bson extension

I'm trying to run mongorestore through docker to restore the database to another dockerized mongo on the system:

sudo docker run --net=host -v $PWD:/home/mongo mongo /bin/bash -c "mongorestore -d venko /home/mongo/mongo_venko_20200326230306.archive"

but I get

2020-03-27T00:17:32.645+0000    the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead
2020-03-27T00:17:32.645+0000    Failed: file /home/mongo/mongo_venko_20200326230306.archive does not have .bson extension
2020-03-27T00:17:32.645+0000    0 document(s) restored successfully. 0 document(s) failed to restore.

Answers from mongorestore error: Don't know what to do with the dump file tell me to pass the -db option but I did pass so I don't know what to do.



Solution 1:[1]

As the error mentions the mongorestore looks for a BSON file, while the archive is not the extension it is looking for.

You can do the following:

  1. Either use:

    mongorestore --gzip /home/mongo/mongo_venko_20200326230306.archive

  2. Or, Extract the archive file and use:

    mongorestore /home/mongo/mongo_venko_20200326230306/<filename.bson>

Solution 2:[2]

I have to use both options --gzip and --archive

mongorestore --uri="uri" --gzip --archive=/Path/to/archive/abc.gz

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mushahid Khan
Solution 2 ?? Công B?ng