• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

How do YOU backup your Hyper-V VM's?

jadams

2[H]4U
Joined
Mar 14, 2010
Messages
4,086
I'm looking to backup the VHD's. I'd like for it to be automated, but this involves shutting down the VM's. Shutting them down isnt an issue, but it kind of kills the "automated" process.

I've researched and saw people use a powershell script to shutdown VM's. This would be great, but all the powershell programming is way over my head at the moment.

What do you guys suggest?
 
I don't know if this is possible, but why can't Windows use VSS to backup a vhd file while its in use?
 
http://www.bunkerhollow.com/blogs/matt/archive/2008/09/24/hyper-v-vm-backup-script-batch-file.aspx

answered myown question. Pretty easy to follow and setup. I'm going to modify it to shutdown,copy, then start one at a time, instead of shutting them all down and copying then starting all again. too much downtime for that. Also use xcopy to copy an whole folder rather than the copy command. I have snapshots that need copying too and would rather just copy the whole folder that the VM resides in rather than individual files.
 
Id like to know how to backup the vm's to, however for me shutting them down is not possible, how do we / you backup vm's when they are running ? how do you backup the hyperv server with out taking it off line etc etc.

How do companies backup their vm's ?

Are their vm's on a nas / iscsi unit not on internal hard drives ?
 
I always assumed you backed up a VM the same way you did a physical machine, by treating it just like a physical machine.

To backup the VHD's that reside on the host server I dont think theres a way around having to shut them down.
 
I guess i have some more reading to do then. Good thing my new V-server is going to have 6 drives and raid6 :)

j'
 
We use System Center Data Protection Manager. Using the VSS writer you take incremental snapshots and backup online as long as the guest OS is 2k3 or greater..you should be able to support that, if not the VM goes into Hibernate during the backup.

We do backups to SAN and to Tape with this product and it works extremely well. It better, for the price, and the fact that it's Microsoft's product.
 
Using the Hyper-V powershell modules we defrag the disk on the live VM first, then shut it down, compact the vhd, export it, and then turn it back on. Depending on the size of the vhd this can take anywhere from 2 to 30 minutes for us. We do them one at a time, on Sundays usually sine all of our locations are closed on sunday and no one is working.
Code:
$vm = "LXM-WSUS7"
$server = "lxm-it-hyperv1"
$objVM = Get-VM $vm $server

if ($objVM.EnabledState -match "2"){
Invoke-VMShutdown $objVM wait -force
}

$objVMDisk = Get-VMDisk $vm $server | Where {$_.DriveName -match "Hard Drive"}
$objvmDisk.Diskpath
Compress-VHD $objVMDisk.DiskPath $server -wait
Export-VM $objVM -path "Y:\EXPORT\" -wait -copystate
wait-event -timeout 10
Set-VMState $objVM Running -wait


This code doesnt include the defrag portion as I don't have the full copy on my home PC, but I can post it later if you want.

The hyper-v modules can be found here
http://pshyperv.codeplex.com/

I typically run the scripts manually but they can be scheduled using task manager.
 
For coprorate use? A couple grand and you can use symantec backup exec vmclient. It will packup as many vms on your host.
 
Back
Top