MyLVMbackup: Making it cooperate with Debian

For making a consistent backup of MySQL data, mylvmbackup seems to be a great tool. It's written in Perl and does what you would expect: Lock the tables, flush them all to disk, make a LVM snapshot and release the tables, recover the InnoDB log,make the backup from the snapshot, remove the snapshot. Minimal downtime and still a consistent backup. Although it's fairly new, it looks good.

There's even a Debian package for it, but that doesn't really contain everything I need. First of all, I need a package that runs on Etch. There's a dependency in the Debian package (which is for Lenny) on an asciidoc of a version that's available only in Lenny. I don't really see why that dependency is there at all, but when removing the version, the package still works as expected.

Also, I made two patches of which one is not needed at all, but I left it in there anyway, because it doesn't break anything. It simply adds the --innodb-file-per-table option to the invocation of the mysqld_safe daemon, but that's not needed since it only affects MySQL when you change data. But since mysqld_safe is used to recover from logs, you won't be changing data. I left it in there anyway. You can find the dpatch file here.

The second one might be more interesting. The mysql-server-5.0 package from Debian creates a file /etc/mysql/debian.cnf with login details for the debian-sys-maint user. This user also has enough permissions to do all the things necessary for manipulating the database when we want to make a backup with mylvmbackup. Normally, mylvmbackup needs you to give it user details for a privileged user in /etc/mylvmbackup.conf, which is a bit double, since the debian.cnf exists. So my patch adds a --defaults_file option which allows you to mention the debian.cnf. No need for more passwords in plaintext on the filesystem! You can either give this option no the commandline or in the mylvmbackup.conf in the [mysql] section. It only supports Debian style debian.cnf, though, since it searched for a [client] section in the file you mention. You can find the patch here.

A working package can be found in Kumina's Debian repository for both etch and lenny. Please let me know if this works for you! It's my first Perl, though, so be warned. If stuff breaks... Well... Sorry... So be sure to test it.


Comments powered by Disqus