Copy VM between two vSphere environments February 8, 2012Posted 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).
- Confirm that there is a clear TCP/22 path opened between ASUKA and COGSWORTH. Coordinate changes with your Firewall Administrator, if necessary.
- Shutdown the WEB2 virtual machine.
- Enable “Remote Tech Support (SSH)” on both ASUKA and COGSWORTH.
- Use your favorite SSH client to login to COGSWORTH.
- Determine what datastore you intend to copy the VM to, and browse to that path:
- Make a directory with the same name as the current VM:
- Open a new session of your SSH client, and login to ASUKA.
- Browse to the path where the VM is stored:
- 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.
- 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.
- When the copy is completed, login to your VI client against the destination environment.
- Use the Datastore Browser to traverse to the path of the files. Right-click upon the VMX file, and select “Add to Inventory”.
- Edit the Settings of the new VM to make any changes appropriate to the environment (network, etc.)
- Power on the VM.
No, it’s not the most ingenious solution… but it got the job done. I hope someone finds this useful.