MongoDb: How to import dump data from .gz file?

不打扰是莪最后的温柔 提交于 2019-12-01 01:21:38

问题


I want to import dump data from my .gz file.

Location of file is home/Alex/Documents/Abc/dump.gz and the name of db is "Alex".

I have tried mongorestore --gzip --db "Alex" /home/Alex/Documents/Abc/dump.gz

But it shows error:

 2018-10-31T12:54:58.359+0530   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
 2018-10-31T12:54:58.359+0530   Failed: file 
 /home/Alex/Documents/Abc/dump.gz does not have .bson extension.

How can I import it?


回答1:


Dump command:

mongodump --host localhost:27017 --gzip --db Alex --out ./testSO

Restore Command:

mongorestore --host localhost:27017 --gzip --db Alex ./testSO/Alex

Works perfectly!


While using archive:

Dump command:

mongodump --host localhost:27017 --archive=dump.gz --gzip --db Alex

Restore Command:

mongorestore --host localhost:27017 --gzip --archive=dump.gz --db Alex

Note:- While using archive you need to stick with the database name.

Different database name or collection name is not supported. For more info.



来源:https://stackoverflow.com/questions/53078520/mongodb-how-to-import-dump-data-from-gz-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!