Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restore gzipped Monogdb single collection?

Hye everyone, I am new to mongodb I dumped one of my collection using following command mongodump --db somedb --collection somecollection --out - | gzip > collectiondump.gz given on the link now when I try to restore it using mongorestore it gives Error dont know what to do with file.

kindly help me I used this way because the answer in the given link got too much upvotes

Error image

like image 523
zish Avatar asked Jan 31 '26 21:01

zish


2 Answers

You can just add gzip to the restore command:

mongorestore --gzip --db projectx userprofiles/
like image 189
JAR.JAR.beans Avatar answered Feb 02 '26 15:02

JAR.JAR.beans


Okay I have got my answer first of all I converted the extension of my gunzipped file to bson by using command

gunzip -c userprofiles.gz > users.bson

after that I used mongorestore command

mongorestore --db projectx userprofiles/

Thats it

like image 25
zish Avatar answered Feb 02 '26 15:02

zish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!