Creating backups and compressing files are always time-consuming tasks. For example, creating the daily backup of the Kinja-related databases took about 6,5 hours every day. The first part of creating the backup itself is a task about 40 minutes long – that’s the time of the run of innobackupex, and applying the changed logfiles to db. (I’ll write about this later!) The second part of the backup is to compress files before they are copied to the storage server…and this step took about 5,5 hours. I have written this part of the backup script with the old-fashioned compression utility – gzip (and tar of course!)
# Normally this is the way, how you compress a tarfile on the fly:
tar -czf backup.tar.gz /path/to/backupdir
This is totally awesome most of the time, but you have to know one thing: gzip only uses one processor core during the operation, so if you have beefy hardware, you can’t even scratch the total throughput your machine could do.
So, the solution is to parallelize the whole operation.
Here is a good comparison of parallel compression software.
I’ve decided to use pigz, so I’ve modified the relevant part of the backup script like this:
tar -c --use-compress-program=pigz -f backup.tar.gz /path/to/backupdir
The result could be read from this article’s head image: the compression itself completes in half an hour (this is 11 times faster than before!)
So my part of rebuilding the developer’s database could be completed before the devs started using it. (hm… I think this will be a new post too.)