Erik's Weblog 2.0

June 20, 2006


Backing MySQL Up

I've seen quite some talk about various Automatic MySQL Backup scripts. Maybe I'm missing the point, but backing up MySQL databases is not rocket science. I use a very simple logrotate script:

/etc/logrotate.d /mysql-backup
/opt/backups/mysql-backup.sql {
  rotate 15
  # just if mysqld is really running
  if test -n "`ps acx|grep mysqld`"; then
    /usr/bin/mysqldump --user=USER --password=PASSWORD --add-drop-table --add-locks --all --extended-insert --quick -A > /opt/backups/mysql-backup.sql

Logrotate provides all kinds of configuration options. There's really no need to reinvent the wheel.