Home > database >  Mongorestore in gz file
Mongorestore in gz file

Time:12-21

I'm trying use mongorestore with gz file:

i've the following directory:

__/tmp/bkp/dbbkp
   |__ collection1.bson
   |__ collection1.metadata.json
   |__ collection2.bson
   |__ collection2.metadata.json
   |__ collection3.bson
   |__ collection3.metadata.json

and i'm using tar -cvzf /tmp/bkp/dbbkp.gz /tmp/bkp/dbbkp/*

and now i've the following files

__/tmp/bkp/dbbkp/
__/tmp/bkp/dbbkp.gz

now i want

mongorestore --gzip --archive=/tmp/bkp/dbbkp.gz

but i get this message

Failed: stream or file does not appear to be a mongodump archive

how can i use mongorestore in dbbkp.gz?

CodePudding user response:

Mongorestore does not read tar files. It can only read archives created by mongodump.

With that example tar, you would need to extract the files first, then run mongo restore on the directory.

  • Related