Hello,
may I please ask for a little advice?
I have a KVM VM (Centos 7 on ext4 fs, no LVM inside VM) with mysql server running inside. I'd like to create whole host backup (via snapshot method to minimize mysql server downtime) but what I afraid of, when I do snapshot of VM the fs consistency seems to be ok but the database binary files itself may not be consistently saved. That is, as I restore such a backup I can see mysql errors which will be the problem to combat later.
On the other hand, the PVE's backup script does the following:
1. Lock the VM for backup
2. Create snapshot of VM's volumes
3. Create archive but the VM itself can run since the backup uses snapshoted volumes.
4. Unlock the VM to be run as usual.
So I'd like to add something to the process: to do LOCK statement(s) on MySQL DBs inside the VM. That is, add FLUSH and LOCK before #2 and UNLOCK after #2. This way the MySQL will be backed up consistently (I suppose) and the downtime will be minimized.
So the question is, how can I add my commands to backup process? I can copy standard backup script and add changes needed but which script should I change then? I can even run it on my own cron, not on PVE-controlled one.
P.S. How's my idea, if it is alive, or I will get extra troubles on that?
may I please ask for a little advice?
I have a KVM VM (Centos 7 on ext4 fs, no LVM inside VM) with mysql server running inside. I'd like to create whole host backup (via snapshot method to minimize mysql server downtime) but what I afraid of, when I do snapshot of VM the fs consistency seems to be ok but the database binary files itself may not be consistently saved. That is, as I restore such a backup I can see mysql errors which will be the problem to combat later.
On the other hand, the PVE's backup script does the following:
1. Lock the VM for backup
2. Create snapshot of VM's volumes
3. Create archive but the VM itself can run since the backup uses snapshoted volumes.
4. Unlock the VM to be run as usual.
So I'd like to add something to the process: to do LOCK statement(s) on MySQL DBs inside the VM. That is, add FLUSH and LOCK before #2 and UNLOCK after #2. This way the MySQL will be backed up consistently (I suppose) and the downtime will be minimized.
So the question is, how can I add my commands to backup process? I can copy standard backup script and add changes needed but which script should I change then? I can even run it on my own cron, not on PVE-controlled one.
P.S. How's my idea, if it is alive, or I will get extra troubles on that?