Run script during Hyper-V VM snapshot creation in VM

@uroni I solved question about seed with backup api.

But I have another:

When urbackup made backup of 2 Linux VM on hyper-v server, probability of inconsistency MySQL or other database very high on live VM.
I run script prefilebackup.bat, which made incremental backup of database, but how run this script on each backup of Linux VM?

As far as I know, Hyper-V integrates with Windows VSS, but mysql doesn’t support that ( ). So unless you find a VSS writer that lets you run commands I know of now way.

I’d just make sure the Mysql is configured to sync to disk on commit and then backups should be consistent no matter how much application support there is.

I want call ssh in prefilebackup.bat, which made xtrabackup in guest VM, before VSS take snapshot. Please explain about snapshot? If I have more than 1 vm, vss take snapshot once on beginning of all backups?

@uroni in veeam blog I found article about this.

Veeam backup has 2 scripts: pre-freeze script and post-thaw script.
First run before snapshot, second after.

Here is how to do it with UrBackup:

The Linux hyper-v vss daemon freezes file systems per default:

You’ll have to modify this one if you want to execute scripts.
This is all way out of scope since you decided not to run UrBackup in the VM.

And if you find the veeam scripts, you can just use those. The blog entry doesn’t help on that front. Note that Veeam has it’s on Linux kernel module to snapshot, so the link above might not even apply to Hyper-V.


I understand about veeam and VMware.

But I give link about pre-freeze and pre-thaw script (before and after snapshot)

Equal scripts present in veeam backup for hyper-v:

I afraid when vss freeze filesystem, MySQL don’t flush all tables. And data will be lost.

Seems Veeam uses SSH to login to the clients and then run the scripts. I would strongly recommend against this. If somebody gets access to the backup server he can delete all data on the backup server and the clients.

I guess shooting oneself in the foot would be possible with pre image backup scripts on the server (like ), but that is currently not implemented.

Thanks for all replies. Currently I will disable Backup Conponent on VMs.
It’s guaranteed save state of VM and consistency. Disadvantage of this: downtime during backup.

Now that I think about it you can probably implement it using the prefilebackup script on the Hyper-V host. I.e. ssh into the Linux VMs from prefilebackup.bat.