TransWikia.com

Why is my mongo backup thrice my database size?

Server Fault Asked by M4ks on November 14, 2021

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 Answers

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

Answered by Bert on November 14, 2021

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

Answered by EC Tan on November 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP