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/
Percona guide to LVM MySQL Backups
1) Connect to MySQL and run
FLUSH TABLES WITH READ LOCK
2) While holding connection open run:
lvcreate -L16G -s -n dbbackup /dev/Main/Data – This will create snapshot named dbbackup for Logical Volume Main/Data . You should specify enough of undo space to hold modifications during backup process – I’ve specified 16GB in this case. If your undo size is not large enough snapshot will get invalidated and backup will be aborted.
Sometimes you might run into the errors on this step, The most common one I’ve resently seen is: snapshot: Required device-mapper target(s) not detected in your kernel – This means snapshot module is not loaded in your kernel by default and you need to load it, which is done by running
3) Now you have created logical volume and can unlock the tables, but before that you should probably record binary log position which is done by running
SHOW MASTER STATUS – This is binary log position you’ll need to point your MySQL Slaves created from this snapshot.
4) Snapshot created, now you want to let MySQL Server to continue, which is done by running
UNLOCK TABLES or simply closing connection.
5) Mount backup Filesystem:
mount /dev/Main/dbbackup /mnt/backup
6) Copy data to backup. Normally you can skip slow query logs and error log while taking backup. You also can skip most of binary logs – however if some of your slaves are far behind you might want to keep some of last binary logs just in case, or you can assume in case of recovery from the backup you will need to restore slaves as well and skip binary logs in your backup process.
7) Unmount filesystem
8) Remove snapshot:
lvremove -f /dev/Main/dbbackup
If you want to create slave based on such snapshot you need to perform couple of more simple steps
9) Extract/Copy database to the slave database directory.
10) Start MySQL Server. Wait for it to perform recovery.
11) Use CHANGE MASTER TO to point slave to saved binary log position: change master to
master_host="master", master_user="user", master_password="password", master_log_file="host-bin.000335", master_log_pos=401934686;
SLAVE START to restart replication.