Monthly Archives: December 2016

How to copy VMs directly between ESXi Hosts using ovftool

I need to copy a Virtual Machine from one host to another, if you do not have shared storage sometimes it’s could be a little difficult. On my HomeLab I have two hosts (micro servers). I wish to copy, not to move the VM from host. I can leverage tools like VMware Converter or exporting the VM to OVF and then re-importing that VM into the destination host but it could take awhile or I have to run a Windows system (I have but I don’t like). If you are looking for a quick and easy way to copy a VM from one host to another, try using the ovftool (yes, I know that PowerCLI now works on a Mac System, even I have it, but that topic will be another article on my blog).

My HomeLab’s first host has the IP address (the source), and the target host has the address

I had used ovftool before for convert a VMware Fusion VM to OVF file. Then when I tried to use to export VMs I got this error:

root@mymacpro:$ ./ovftool vi://root@
Segmentation fault: 11

Because I found some references where people had used ovftool to export VMs, like virtuallyGhetto site, I guessed my problem was the version.

I checked my Mac has the version: 3.5.2:

aavelar@mymacpro:$ ./ovftool -v
VMware ovftool 3.5.2 (build-1880279)

I looked for a new one version, and I found the version 4.2.0 available on VMware site (VMware-ovftool-4.2.0-4586971-mac.x64.dmg file). After I installed the new one version, I checked again:

aavelar@mymacpro:$ ./ovftool -v
VMware ovftool 4.2.0 (build-4586971)

We are ready. First, I need to check what is the list of VM’s on the source host:

aavelar@mymacpro:$ ./ovftool vi://root@
Enter login information for source vi://
Username: root
Password: ********
Error: Found wrong kind of object (ResourcePool). Possible completions are:
VMware vCenter Orchestrator Appliance
VMware vCenter Server 6
VMware vCenter Orchestrator Appliance OTB
vRealize Infrastructure Navigator
VMware vRealize Appliance 7.0
Redhat Enterprise Linux 7.2 x86_64

I choose “vRealize Infrastructure Navigator”, just because it’s the little one. Also I need to define what is the datastore on target host, I chose datastore_1_Server1 datastore. We are ready, go:

aavelar@mymacpro:$ ./ovftool -ds=datastore_1_Server1 vi://root@\ Infrastructure\ Navigator vi://root@
Enter login information for source vi://
Username: root
Password: ********
Opening VI source: vi://root@
Opening VI target: vi://root@
Deploying to VI: vi://root@
Transfer Completed
Completed successfully

Also, you can create some too simple script to do the task for each VM on source host, in my case it could be:

  1. #!/bin/bash
  4. OVFTOOL="/Applications/VMware\ OVF\ Tool/ovftool"
  5. OIFS="$IFS"
  6. IFS=$'\n'
  7. VMs="VMware vCenter Orchestrator Appliance
  8. VMware vCenter Orchestrator Appliance OTB"
  10. for vm in ${VMs}; do
  11.     echo "${vm}"
  12.     echo $OVFTOOL -ds=datastore_1_Server1  vi://root:VMware1\!@${vm} vi://root:VMware1\!@
  13. done
  15. IFS="$OIFS"

Done. The VM’s were copied. Remember, with this method you will copy the VM, not move it. Then, after you are sure the VM was copied fine, you need to remove the old one VM from the source host (after you tested the new copy is working).