Wednesday, March 10, 2010

How to backup VMWare Virtual Machines?


As you may already know - backing up virtual machines isn't a walk in the park. Actually, it is very much similar to usual backup process of any physical machine. However, VMWare has a nice tool called "VMware Consolidated Backup" which can do even online backups of virtual machines, without disrupting users and applications. Of course this tool isn't free. So, we are back at the begining of this story - how to backup virtual machines.

There are few ways to do manual backup of virtual machines which can then bi scripted into a semi-automatic backup or automatic backup if you whish. The down side of this approach is that you have downtime of virtual machine when doing backup, but in most cases I find this acceptable.

We are using VMWare server 2.0 platform for our virtual machines. There are few requirements in order to do this. First, you need to familiarize yourself with vmrun command line tool. Vmrun is used for managing virtual machines from command line. This and other Vmware tools are by default located in c:\Program Files\VMWare\VMware Server\.

This is what I use for "soft" stopping virtual machine SPWFE1.domain.local located at E_DRIVE datastore of VMWare Server named VM.domain.local. I am using local administrator user context for running this command i.e. user:admin with password:wordxxxx

From command prompt run: "vmrun -T server -h https://vm.domain.local:8333/sdk -u admin -p wordxxxx stop "[E_DRIVE] spwfe1\spwfe1.domain.local.vmx" soft"

This command, shutsdown virtual machine spwfe1.domain.local after ending all processes.

Now, we need to go to next step, which is copying the virtual machine to another location i.e. making backup of the virtual machine. In order to do that - I use xcopy command to copy folder content to another location.

After copying is done, we can start the virtual machine by running command "vmrun -T server -h https://vm.domain.local:8333/sdk -u admin -p wordxxxx start "[E_DRIVE] spwfe1\spwfe1.domain.local.vmx"

The final thing, in order to automate this, you should organize stop, copy and startup scripts into different scripts and use either windows AT command or Scheduled Tasks to schedule starting of these scripts.

No comments:

Post a Comment