Erik's Weblog 2.0

June 20, 2006

[@322]

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 {
  notifempty
  daily
  nocreate
  rotate 15
  missingok
  compress
  postrotate
  # 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
  fi
  endscript
}


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