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.
Basic mongorestore syntax The basic way to restore a database is to use the mongorestore command to specify the backup directory (dump directory) without any options. This option is suitable for databases located in the localhost (127.0. 0.1) using the port 27017.
However, mongorestore performs inserts only and does not perform updates. That is, if restoring documents to an existing database and collection and existing documents have the same value _id field as the to-be-restored documents, mongorestore will not overwrite those documents.
If there are also bson files in the dump/local directory, mongorestore restores them like normal collections. For an example of --oplogReplay, see Restore Point in Time Oplog Backup.
If the database does not exist, mongorestore creates the database. For example, the following restores the salaries collection into the reporting database. If you do not specify --db, mongorestore takes the database name from the data files.
If there is an oplog.bson file at the top level of the dump directory and a path specified by --oplogFile , mongorestore returns an error. If there is an oplog.bson file at the top level of the dump directory, mongorestore restores that file as the oplog.
You should just be able to do mongorestore --gzip <path to gzip folder). Side note you can use mongodump with --gzip option and it will compress it for you.
I have to use both options --gzip and --archive
mongorestore --uri="uri" --gzip --archive=/Path/to/archive/abc.gz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With