https://github.com/albertomh/py-gmail-scrape https://developers.google.com/gmail/api/v1/reference/users/messages/attachments/get
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/