I'm trying to automatically schedule copying (cloning) a couple of production virtual machines to a DR site across a WAN link.
In VirtualCenter 2.0 I've configured one datacenter containing a production cluster and a DR cluster on each side of the WAN link (100mbps). This allows me to create a series of scheduled tasks in VC to down the vm, clone it to DR and then bring the vm backup. Sounds good so far unfortunately when I try to repeat the process the clone task fails because "The name 'my server name' already exists".
Of course I can delete the DR images manually but I'd really like to automate it (age, stupidity, advancing senility etc)
Any suggestions as to how i might do this? I imagine scripting of some form but don't know where to start and I'll admit to a general lack of scripting and linux\vmware experience (sigh)
I won't profess to be the scripting guru and some of this would likely be far more efficient with the SDK versus commands in a cron job from the COS. Depending on the complexity of your setup however it may work without an issue.
The command you would be looking to use is vmware-cmd, which will allow you to power on, power off, suspend, etc. Then you could use vmkfstools to do the disk copies. The trick to this is that you need to know which ESX server that your VM you want to clone is on. VirtualCenter has visibility into these inventories and therefore you don't need to pinpoint. DRS and any VMotion could complicate the script because you would need to check the server first to make sure the VM is there.
Not sure if there is a budget for this but there are third party off the shelf products that could handle this. Vizioncore, DoubleTake, and even PlateSpin or Acronis all have products that may suit your needs and be a cleaner alternative to a script.
Thanks, I came across vmware-cmd about half an hour after I posted my original message
I tried manually running
vmware-cmd -s unregister 'path to vm'
and then tried running the VC scheduled task again. Sadly it didn't work: the vm machine showed up as 'orphaned' in VC and I got the same error. I guess the orphan was locking the name as far as VC was concerned.
If I can get this working I could add the vmware-cmd to cron (somehow...) and then do the rest of the job with VC scheduled tasks. Not very elegant but should work.
I'll have a look at the third part products (there might be a budget...)
Why shutdown the VM?
esxRanger from vizioncore will do what you desire. As will VCB using a VCB proxy server as long as it can see the remote datastore as a LUN. You can also write your own VCB type copy to another filesystem seen by a secondary machine that would copy the data over the network.
These methods would get the VM to a remote location withou tshutting down the VM.
I use vcbMounter from the COS (no license required) to copy the VM onto an NFS share and then SCP the files from the NFS share to the hotsite and import the VMDK into it.
Thanks for you help again
I haven't implemented VCB. We use Backup EXEC 11d and when I was looking at VCB Symantec weren't supporting 64-bit ESX. However your suggestions made me go back and check again. Happily 64-bit ESX is[/u] now supported. So I think I'm going to have another go at VCB (not just for this issue).
(I'll probably also have a look at esxRanger: Plan B)
I'll update this as thing progress
I am looking to do the same as you. I am using the P2VTool.exe to p2v a physical server over to our DR site on a monthly basis. This tool will not allow me to overwrite the existing powered off VM, so I would like to delete the VM first then P2V the server. I haven't been able to find a good solution, but have come up with the following few lines that can be run from the console. Now I just need to figure out how schedul multiple instaces of this during different parts of a month (and times)
vmware-cmd s unregister /vmfs/volumes/....
rm - /vmfs/volumes/..../VMFolder
Message was edited by:
I think you have the answer there. I've gone down the VCB\Backup Exec route to capture my images. I then copy them with a scheduled batch file.
I think I can use your script to complete the process.
(I guess you'll be looking into cron to schedule your scripts)