开发者

Archive SQL dumps better?

开发者 https://www.devze.com 2023-01-15 07:45 出处:网络
I am dumping my SQL db with the script below. My site isnt used often so the DB is unchanged for days. The only difference is the last line which is the dump date. Each dump is about 400k uncompressed

I am dumping my SQL db with the script below. My site isnt used often so the DB is unchanged for days. The only difference is the last line which is the dump date. Each dump is about 400k uncompressed and 107kb as a .sql.gz file. I decide to compress them as a solid archive with 7z and rar. In both cases i get 950kb with 32files. I feel i should get better compression. How?

#!/bin/bash
cd /home/mybackup/mysqldumps
y=$(date +%Y)
m=$(date +%m)
d=$(date +%d)
h=$(date +%H)
mkdir $y
cd $y
mkd开发者_开发知识库ir $m
cd $m
mysqldump --all-databases --single-transaction --flush-logs | gzip > "$y $m $d $h.sql.gz"
chmod 400 "$y $m $d $h.sql.gz"


Uncompress all the .sql.gz to regular sql files. Compress the folder. Results were 88kb while compressing the files as .sql.gz were 950k. Thats huge savings.


In this day and age 950k is a tiny amount of storage space. If you go with a simple grandfather, father, son backup rotation you're looking at about 22Mb for a year's worth of backups. Or five or six MP3 files as comparison.

Even if you are on dialup (or GPRS/1xRTT in a pinch) this is still a manageable amount of data to transfer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号