Percona XtraBackup is an open-source hot backup utility for MySQL that doesn’t lock your database during the backup. It can back up data from InnoDB, XtraDB, and MyISAM tables on MySQL 5.0 and newer servers, and it has many advanced features. Commercial support contracts are available. For a high-level overview of the features, including a feature comparison, please see the XtraBackup homepage.

Luckily installing XtraBackup is pretty easy

$ sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
$ echo "deb http://repo.percona.com/apt maverick main" | sudo tee -a /etc/apt/sources.list
$ sudo apt-get update<br /> $ sudo apt-get install xtrabackup

I wrapped the backup program in a small shell script

#!/bin/bash
BDIR="/home/backup/mysql"

# Run backup
/usr/bin/innobackupex-1.5.1 --stream=tar --defaults-file=/etc/mysql/my.cnf ./ | gzip -c -9 > $BDIR/backup.`date +%m%d%Y%H%M%S`.tar.gz

# Remove backups older than 7 days
find $BDIR -name backup.\* -ctime +7 -exec rm {} \;

I prefer to have the the username and password for MySQL in my.cnf (add these lines under [client])

user           = root
password    = Secreeet

Finally, add the script to root’s crontab (you know, sudo crontab -e)

0 2 * * * bash /usr/local/bin/mysql_backup.sh > /dev/null 2>&1