Skip to content

Instantly share code, notes, and snippets.

View L04DB4L4NC3R's full-sized avatar
😏
Noob is just a state of mind

Angad Sharma L04DB4L4NC3R

😏
Noob is just a state of mind
View GitHub Profile
@L04DB4L4NC3R
L04DB4L4NC3R / description.md
Last active September 5, 2019 21:56 — forked from lsm/export_gridfs.sh
Export files from MongoDB GridFS with directory paths

So mongodb stores every document in the form of bson. A bson document has a max limit of 16 MB. Therefore mongodb uses something known as gridFS when saving huge files. It creates fs.chunks for storing base64 files and fs.files to store file metadata.

mongodump creates a dump of the whole DB. Like a bson snapshot. But due to version changes we have to run it in a docker container which has mongoDB 4.0 installed. It shows permission denied while creating a file. So I just exec'ed into the container to run the mongodump command.

docker run --rm -v $(pwd):/workdir/ -w /workdir/ mongo:4.0 mongodump -h server -d $database --out /workdir/dump/