Tablets How to Backup Hyper-V Virtual Machines with a Batch File | BLOG IT

How to Backup Hyper-V Virtual Machines with a Batch File

A big advantage to have a virtual computer is that you could take a backup entirely without too much problem, you only need enough free space to do it and the Windows Backup.

I will show you how to backup a Virtual Machine hosted on a Windows 2012 R2 server, this commands are very useful on Windows Core Edition but are too appreciated for GUI Edition.

You need to take in count that is very recommendable to backup the VM over external hard disk or over a network mapping drive, I use the last one and I need to mention that when we use this option the backup is overwritten for the next one, so you only have the last backup for your VM, although you could backup your VM backup's to other media such as tape if you need to retain your backup for certain time.

I have a batch file which runs every night through an Schedule Task and take a backup for every VM located on my Windows 2012 R2 Core Edition Server, the batch starts mapping the network drive:

  • Net use \\DestinationServer\ShareForVM01 /user:BackupUser Password

  1. Where DestinationServer is an outside server with enough free space, ShareForVM01 is the shared folder for VM01 you need one share folder for every VM because if you have just one the last VM backed up will overwrite the last one and you will lost your other VM backup's. 
  2. /User is the user with enough privileges to write files on the shared folder.
  3. Password is the password for the user which perfmon the backup.

You will need several's Net Use entries for every VM to backup.

Then you use the command to backup you VM.

  • wbadmin start backup -backupTarget:\\DestinationServer\ShareForVM01 -hyperv:"VM01" -quiet

  1. Where \\DestinationServer\ShareForVM01 is the shared folder for VM VM01.
  2. And "VM01" is your VM name's to be backed up.

You will need one entry for each VM.

The VM is backed up online only with a little delay for the end user, this applies even for Linux VM.

The last step is to disconnect the Network Drives acquired on your first steps as follows:

  • net use /Delete \\DestinationServer\ShareForVM01

I hope this article shows you how to backup easily your VM, for me had been very useful.


About Robert SA

    Blogger Comment
    Facebook Comment

0 comentarios: