h1

Backing Up MySQL dumps

October 23, 2007

On the heals of my un-deletion catastrophe, I thought It would be a good idea to automate a backup routine that would insure that I always have good MySQL dumps. Using logrotate, I crafted a config that will keep 30 days worth of compressed dump files. I made one for each MySQL schema (database) that I deemed critical.

I create two files in the /etc/logrotate.d, one fore each database, and it looked something like this

/var/backup/mysql/schema.sql {
rotate 30
daily
compress
create 644 mysql adm
dateext
maxage 30
prerotate
/usr/bin/mysqldump -u user -ppassword schema > /var/backup/mysql/schema.sql
endscript
}

It is interesting to note that since the DUMP files are just SQL Text, and repeatable data, they compress quite nicely (18 MB dump shrinks to 2.5MB) and since I have over 30 gigs on this 32 gig drive, I think I will be fine.

I use MySQLDump instead of backing up the actual files themselves because they are a bit more portable, and can always be manually checked, tweaked, or repaired if needed.

About these ads

One comment

  1. Thanks, good and easy description



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: