So I was looking into LVM snapshots and it seems like a feasible method for backing up mysql so that it's at least crash consistent.
My issue is that I have mysql servers where the mysql data directories live on a SAN and I'd like to utilize the arrays snapshotting capability for the mysql LUN.
I was thinking that I could add a second LUN, create a PV on it, add it to the VG on the server, create an LV that would be a snapshot of the mysql LV and mount that.
At this point, i could copy the data to wherever i needed to copy it.
That part is good but it takes time to do and depending on the size of the database because I have to actually copy the data.
Once I have the snapshot created, Can i take an array snapshot of the mysql LUN and then release the LVM snapshot and remove it?
has anyone tried this?
My understanding is that the changes made after an LVM snapshot are stored on the snapshot LV. Is this correct?
thanks!
Best Answer
I don't see a problem with it at all. Just make sure you have plenty of space free in the
lv
holding the snapshot, so that you don't run out of time copying the files elsewhere (otherwise the snapshot will be dropped).The typical process for MySQL backups via snapshot is to first flush with read lock, then start the snapshot, then release the read lock. At that point, you can copy the
/var/lib/mysql
directory to wherever you want - and do whatever you want with it.The Percona crew did a good article on it here, http://www.mysqlperformanceblog.com/2006/08/21/using-lvm-for-mysql-backup-and-replication-setup/