2

I have a mongodb, and there is some data inside. Now much, a bit more then 5GB.

> show dbs;
local  0.000GB
aaaa   0.034GB
bbbbb  5.327GB
> 

So I made a backup, using mongodump -h mongo --archive > mongo.tar.

However, this file is 16GB in size

root@box:~$ ls -lah | grep mongo
-rw-r--r-- 1 root root  16G Oct  7 12:48 mongo.tar

Which is more then three times bigger then reported dataset size. I can compress it, of course, but I would like to know why is the backup so big in the first place.

2
  • I don't know MongoDB, but I guess that the database files are in binary format, while the database dump is in text format. The reason for this would be to have a way for moving data between versions where database file format has changed. Oct 10, 2016 at 17:11
  • What version of MongoDB are you using, and if >3.0 what storage engine?
    – Stennie
    Nov 29, 2016 at 14:42

2 Answers 2

-1

Databases use sparse files which don't automatically re-use cleared storage. You will need to compact the file to reduce its size, mongo can achieve this with the '--repair' option

-3

You can use --gzip flag to compress the output file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.