I had this as a challenge, we have SAN replication, so you could replicate and promote your storage to achieve the same thing, but I was looking for a quick and dirty way to get a VM from one data centre to another data centre quickly and easily.
So in this example I have two ESX hosts, one in each data centre.
– S1ESX01 (ESX Host)
On each a datastore called S1DATA1 and S2DATA1 respectively. With a VM called SERVER1 that I want to move from one datacentre (and its associated storage) to another datacentre and its associated storage.
1. Firstly you need to open “Security Profile” for the two hosts in question, essentially you need to allow SSH Server and SSH Client from each through the firewall (you could just one or the other for whichever is the client and server, but in this example I’m enabling both). So you click on firewall and tick the allow box for “SSH Server” and “SSH Client.”
2. Connect to SSH session on the ESX Host S1ESX01 then run this command below. Note the VM needs to be turned off!
# scp -r /vmfs/volumes/S1DATA1/SERVER1 root@S2ESX02:/vmfs/volumes/S2DATA2
Where the following coloured in bits are:
S1DATA1 = Source datastore containing the SERVER1 VMDK files.
SERVER1 = Name of the folder containing the SERVER1 VMDK files.
S2ESX02 = Destination ESX host you want to connect to in the other Data Centre.
S2DATA2 = Destination datastore where you want to copy the SERVER1 VMDK files.
3. Now once the file is completed copying, SSH to the destination host S2ESX02.
4. Change directory to where the VM is stored primary disk (i.e. cd /vmfs/volumes/S2DATA2/SERVER1)
5. Make a note of the datastore identifier, i.e. the real name which will be something like: “432ab456-c7ef89e0-12baf3c4567d”)
6. Edit the .VMX file using VI, so run: vi SERVER1.vmx.
7. Replace the directives for the disks with the datastore identifier you copied in step 5.
8. Save the .vmx file (in VI, type “:wq”)
9. Verify within VSphere that the paths are all valid and then fire up the VM. You may need to change the IP address and DNS settings etc to restore network connectivity.