Thursday, March 28, 2013

Copy VMs from one ESXi host directly to another

I found out today that esxi's firewall prevents outgoing ssh by default.  It was blocking my scp attempts.  Once I turned it off (vsphere client->host->configuration->security profile->firewall properties, check the ssh client box and hit ok), it was a simple matter to clone the one host to the other by enabling ssh on both, logging on as root to the target machine, and running

scp -r root@sourcehost:/vmfs/volumes/datastore1/* /vmfs/volumes/datastore1/

And that cloned all the VMs.  Change the firewall back when you're done and all that's left is registering them with esxi and dealing with any guest OS license/SID issues.  If you use the vmware ovftool, it will be faster (my observation, not based on real benchmarking) and automatically register your vm with the target host, but you have to leave the machine running the ovftool running and connected to your network or the process will die.  Also, no wildcards with the ovftool so you have to do the VMs one by one.

No comments: