# Why are backups so large?

**URL:** https://meta.discourse.org/t/why-are-backups-so-large/31401
**Category:** Feature
**Created:** [7월 24, 2015, 5:54오후 UTC](https://meta.discourse.org/t/why-are-backups-so-large/31401 "2015-07-24T17:54:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![BCHK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bchk/32/3268_2.png) [@BCHK](https://meta.discourse.org/u/BCHK)
#### Post date: [7월 24, 2015, 5:54오후 UTC](https://meta.discourse.org/t/why-are-backups-so-large/31401/1 "2015-07-24T17:54:30Z")

</div>

We have about 250,000 posts from 25,000 topics - and our database / backup is about 4.5 backups (I have it set up for 2 backups - so I think the post database is about 2.25 Gig.

That seems really large for what are essentially short, simple text files.

Is there anyway that can be made smaller? How about a simple compression algorithm included so that we can save space on our backups?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [7월 24, 2015, 7:09오후 UTC](https://meta.discourse.org/t/why-are-backups-so-large/31401/2 "2015-07-24T19:09:30Z")

</div>

pg\_dump supports compression:

`-Z, --compress=0-9`

You just need to balance between time spent VS file-size.

Maybe patch [this file](https://github.com/discourse/discourse/blob/9ce66038647bc4ff63167fe9c74857a01acc0875/lib/backup_restore/backuper.rb#L188) and add a small compression level (2~3) and measure the impact on your workload.

In my starting database (10 posts, 50 users) I see the following:

`-rw-r--r-- 1 postgres postgres 2,2M Jul 24 16:04 back_Z_2 -rw-r--r-- 1 postgres postgres 11M Jul 24 16:04 back_no_compression`

`  
Compression (Z=2)  
real 0m0.557s  
user 0m0.072s  
sys 0m0.032s

No Compression  
real 0m0.837s  
user 0m0.280s  
sys 0m0.036s  
`

But you need to use some real data to really commit to this. Using Meta would be a good example.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [7월 24, 2015, 7:19오후 UTC](https://meta.discourse.org/t/why-are-backups-so-large/31401/3 "2015-07-24T19:19:57Z")

</div>

Backups are compressed, that’s what the `.tar.gz` extension means. It is basically `.zip` for UNIX:

 ![](https://global.discourse-cdn.com/meta/original/3X/6/0/60fa1c7957c885b81fa454a52ac93366167f25d1.png) 

That’s a 742 MB backup that is compressed into a 415 MB file:

 ![](https://global.discourse-cdn.com/meta/original/3X/8/7/87ed7ff3931be9c406df8f55594a3a9e73be7bfa.png) 

It does include uploaded images, if you extract it:

![](https://global.discourse-cdn.com/meta/original/3X/c/7/c70d15190bdbe8e1bf36c4a4fce189a871d6b457.png)

The `uploads` folder is 314 MB across 6,947 files and 116,168 folders (!).

You can get smaller backups by opting not to include the uploaded images as well, but it won’t be a complete archive of the content (text and images) that makes up the topics on your site!

Remember images are not very compressible. But text is. If I compress just `dump.sql` alone with 7zip it goes from 339 MB to 60 MB.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [7월 24, 2015, 10:02오후 UTC](https://meta.discourse.org/t/why-are-backups-so-large/31401/4 "2015-07-24T22:02:21Z")

</div>

Images in posts are usually a very large percentage of backup size

---

<div class="post-metadata">

### Author: ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)
#### Post date: [12월 4, 2025, 11:36오전 UTC](https://meta.discourse.org/t/why-are-backups-so-large/31401/6 "2025-12-04T11:36:50Z")

</div>


