Simple question:
$ mongorestore --gzip ./Mongo_DB_dump/restore-8f05kcbfhfbce745735eff49.tar.gz
2020-07-09T18:10:48.207-0500 Failed: file .\Mongo_DB_dump\restore-8f05kcbfhfbce745735eff49.tar.gz does not have .bson extension
2020-07-09T18:10:48.209-0500 0 document(s) restored successfully. 0 document(s) failed to restore.
How can I restore a database using a ´tar.gz´ file if I don't know the name of the database? I'm trying to import a dump from a production instance (MongoDB Cloud) into my local environment. I don't have any previous version of the database in my local if that's relevant.
I also tried to use mongostore --gzip
using the .tar.gz file and also I tried extracting the contents into a .tar file but, with both files I got the following error:
2020-07-09T22:33:07.127-0500 Failed: file .\Mongo_DB_dump\restore-8f05kcbfhfbce745735eff49.tar.gz does not have .bson extension
2020-07-09T22:33:07.128-0500 0 document(s) restored successfully. 0 document(s) failed to restore.
I also tried using /archive:<path-to-file>
unsuccessfully:
$ mongorestore --gzip /archive:./Mongo_DB_dump/restore-8f05kcbfhfbce745735eff49.tar.gz
2020-07-09T22:52:59.076-0500 Failed: stream or file does not appear to be a mongodump archive
2020-07-09T22:52:59.077-0500 0 document(s) restored successfully. 0 document(s) failed to restore.
I even attempted to change blindlessly the .tar
extension into .bson
but that didn't worked out of course:
2020-07-09T22:08:24.175-0500 checking for collection data in Mongo_DB_dump\restore-8f05kcbfhfbce745735eff49.bson
2020-07-09T22:08:24.601-0500 restoring Mongo_DB_dump.restore-8f05kcbfhfbce745735eff49 from Mongo_DB_dump\restore-8f05kcbfhfbce745735eff49.bson
2020-07-09T22:08:24.664-0500 finished restoring Mongo_DB_dump.restore-8f05kcbfhfbce745735eff49 (0 documents, 0 failures)
2020-07-09T22:08:24.664-0500 Failed: Mongo_DB_dump.restore-8f05kcbfhfbce745735eff49: error restoring from Mongo_DB_dump\restore-8f05kcbfhfbce745735eff49.bson: reading bson input: invalid BSONSize: 1953719666 bytes
2020-07-09T22:08:24.664-0500 0 document(s) restored successfully. 0 document(s) failed to restore.
I just extracted the contents of the .tar.gz
file to C:\ProgramData\MongoDB\data\db
and overwrite everything there...
I'm not very convinced about this one, but at least I was able to work because this way I got the database, collections and documents visible to Mongo Shell.
Please share a better answer if you know it.