jump to navigation

Copy VM between two vSphere environments February 8, 2012

Posted by General Zod in Tech, VMware.

Recently, I had a situation that required me to move a VM from one vSphere 4.1 environment to another of the same release.  The identical vSphere versions was the only thing that these two environments had in common.  They are using different vCenters, different storage, different networks, etc… and security dictated that we could *NOT* link the two environments together.  So how does one move a VM from one unique environment to another?

Well… you could browse the datastores, download the files (from the source) to a common storage area, re-upload the files (to the destination), edit appropriate settings, and power the VM on.  However, I didn’t have an available 240 GB of disk space to store the VM in the interim; and I really didn’t want to have to copy the data twice.

I needed a way to copy the data directly from one Host to another.  This is a very simple process… but since I’ve never been very Linux command line savvy, there was some learning curve involved.  I post my process here for my own memory (as well as anyone else who cares to leverage it).

In the following example, I’m copying a VM named “WEB2” from the source ESXi Host named “ASUKA” to the destination ESXi Host named “COGSWORTH”.

  1. Confirm that there is a clear TCP/22 path opened between ASUKA and COGSWORTH.  Coordinate changes with your Firewall Administrator, if necessary.
  2. Shutdown the WEB2 virtual machine.
  3. Enable “Remote Tech Support (SSH)” on both ASUKA and COGSWORTH.
  4. Use your favorite SSH client to login to COGSWORTH.
  5. Determine what datastore you intend to copy the VM to, and browse to that path:
    cd /vmfs/volumes/VMFS02
  6. Make a directory with the same name as the current VM:
    mkdir WEB2
  7. Open a new session of your SSH client, and login to ASUKA.
  8. Browse to the path where the VM is stored:
    cd /vmfs/volumes/SAN03/WEB2
  9. Invoke a “Secure Copy” of all files in the directory using the ROOT credentials of the destination server:
    scp *.* root@COGSWORTH:/vmfs/volumes/VMFS2/WEB2
    You will be prompted for the ROOT account’s password.
  10. Leave your SSH client window open, and use it to monitor the progress of the copy.  Depending upon the size of your VM and the connection speeds between the source and destination, it may take a while to complete.
  11. When the copy is completed, login to your VI client against the destination environment.
  12. Use the Datastore Browser to traverse to the path of the files.  Right-click upon the VMX file, and select “Add to Inventory”.
  13. Edit the Settings of the new VM to make any changes appropriate to the environment (network, etc.)
  14. Power on the VM.


No, it’s not the most ingenious solution… but it got the job done.  I hope someone finds this useful.



1. Chad - February 8, 2012

This is great, I’ll be needing to use this sometime this year. And of course I love your hostnames…

2. Kamesh - August 27, 2012

Try Veeam’s FastSCP, this tools allows you to copy files between two hosts managed by different VCs without a need to enable Remote Tech Support Mode. It authenticates with Domain credentials to VC and provides Graphical interface to all your hosts and datastores.


3. General Zod - August 28, 2012

Actually, I just tried Veeam’s quick migration tool for the first time about a week or so ago, and it worked great. It’s a much easier solution. It almost makes me want to delete this post.

4. hmm - October 1, 2014

I followed your steps and now on my destination esxi host, the VM that I added to the inventory says “Unknown (invalid)” on the left side.

General Zod - October 1, 2014

Hey hmm…
Don’t follow these instructions any more. (I should just delete this post.) Check out using Veeam Backup, Free Edition. It will let you backup a VM from one vCenter and restore it to another in one quick process. Much quicker via a nice GUI. These instructions are way too complicated to use by comparison.

5. hmm - October 1, 2014

Nah don’t delete it. I was trying copy a VM to a host running an older version. In the .vmx file there’s a virtualHW.version that needed to be changed. After that I re-added it to the inventory and it starts up (although I can’t get to the console, but that might be an unrelated issue).

6. Henrique - May 28, 2016

Hey, my friend… Looks like it does worked very well. You have really saved my life! Keep writing articles like this, very very good! Thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: