Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongorestore file X does not have .bson extension

Tags:

docker

mongodb

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.

like image 707
PPP Avatar asked Mar 27 '20 00:03

PPP


People also ask

How do I get Mongorestore?

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.

Does Mongorestore overwrite?

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.

How does mongorestore restore BSON files from dump/local directory?

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.

What happens when mongorestore does not specify--DB?

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.

What is--oplogfile in mongorestore?

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.

How do i compress a mongorestore file?

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.


Video Answer


1 Answers

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

mongorestore --uri="uri" --gzip --archive=/Path/to/archive/abc.gz
like image 91
Đỗ Công Bằng Avatar answered Oct 12 '22 21:10

Đỗ Công Bằng