VMware Cloud Community
tickermcse76
Contributor
Contributor

Invalid backing on VM guest NIC's - (SAN volume replication to DR) - how to avoid?

I'm using SAN volume replication to replicate my ESXi "PROD" datastores LUN's to a "DR" site.  The vCenter server in DR is a fresh install, and not a recovered version of PROD vCenter.  The PROD and DR networks don't have IP connectivity to each other, only the SAN replication traffic is allowed between the sites.

I'm able to mount the replicated datastores in DR vCenter, and power on the guests.  But the large majority of the VM guests have "invalid backing" on their NIC's.  I need to manually edit each VM guest and toggle the NIC to the appropriate switch port.  Distributed vSwitches are being used in both PROD and DR.

Is there any way to have the guest VM's be able to retain their NIC setting when imported into DR?  I tried exporting the vSwitch configuration from PROD and importing to DR, but it did not seem to make a difference.  Would I be better off trying to replicate the PROD vCenter to DR?  The primary reason for a separate DR vCenter was to have a system always online and available, and to host VM guests that could readily support DR/recovery tasks.

0 Kudos
2 Replies
homerzzz
Hot Shot
Hot Shot

I do not know of a way to have the VM keep their NIC settings, so I just reset them using PowerCLI. It is quick and easy if your VMs are in the same port group. The script will get a little more complex if you have multiple port groups.

Here is an example of the main command to use:

get-vm $vmname | Get-NetworkAdapter | Set-NetworkAdapter -PortGroup $pgname

0 Kudos
BenLiebowitz
Expert
Expert

I've had a similar issue to this when migrating VMs from 4.1 to 5.5 with a new vCenter.  I ended up writing a PowerCLI script that exports a list of all the VMs in the PROD VC to CSV.  It then connects to the other VC, in your case the DR VC, browses the datastore, adds the VM to inventory, sets the network, places it back into the correct folder, etc.   If you don't want to power them on, you can remove the PowerON VMs section.  In my case, we were upgrading so the script also upgrades the virtual hardware and the tools.

Hope it helps.

-----------------------

#Build the BlueFolderPath function

New-VIProperty -Name 'FullPath' -ObjectType 'VirtualMachine' -Value {

    param($vm)

  $current = Get-View $vm.ExtensionData.Parent

  $path = ""

  do {

  $parent = $current

  if($parent.Name -ne "vm"){$path =  $parent.Name + "/" + $path}

  $current = Get-View $current.Parent

  } while ($current.Parent -ne $null)

  $path.TrimEnd('/')

} -Force | Out-Null

#Build the Get-folderbypath function

function Get-FolderByPath {

  <#

.SYNOPSIS  Retrieve folders by giving a path

.DESCRIPTION The function will retrieve a folder by it's

  path. The path can contain any type of leave (folder or

  datacenter).

.NOTES  Author:  Luc Dekens

.PARAMETER Path

  The path to the folder.

  This is a required parameter.

.PARAMETER Separator

  The character that is used to separate the leaves in the

  path. The default is '/'

.EXAMPLE

  PS> Get-FolderByPath -Path "Folder1/Datacenter/Folder2"

.EXAMPLE

  PS> Get-FolderByPath -Path "Folder1>Folder2" -Separator '>'

#>

  param(

  [CmdletBinding()]

  [parameter(Mandatory = $true)]

  [System.String[]]${Path},

  [char]${Separator} = '/'

  )

  process{

    if((Get-PowerCLIConfiguration).DefaultVIServerMode -eq "Multiple"){

      $vcs = $defaultVIServers

    }

    else{

      $vcs = $defaultVIServers[0]

    }

    foreach($vc in $vcs){

      foreach($strPath in $Path){

        $root = Get-Folder -Name Datacenters -Server $vc

        $strPath.TrimStart($Separator).Split($Separator) | %{

          $root = Get-Inventory -Name $_ -Location $root -Server $vc -NoRecursion

          if((Get-Inventory -Location $root -NoRecursion | Select -ExpandProperty Name) -contains "vm"){

            $root = Get-Inventory -Name "vm" -Location $root -Server $vc -NoRecursion

          }

        }

        $root | where {$_ -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.FolderImpl]}|%{

          Get-Folder -Name $_.Name -Location $root.Parent -Server $vc

        }

      }

    }

  }

}

# Enable connections to multiple vCenters

Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope AllUsers -Confirm:$false

# Connect to Prod VC

connect-viserver PRODVC

# export list of VMs to Migrate to CSV

Get-Datacenter -name "DataCenter" | Get-VM |

Select Name, @{N="Datastore";E={Get-Datastore -VM $_ | Select -ExpandProperty Name}},

  @{N="Network";E={Get-VirtualPortgroup -VM $_ | Select -ExpandProperty Name}},

  @{N="Parent";E={$_.FullPath}} |

Export-Csv "c:\migrate.csv" -NoTypeinformation -UseCulture

# Connect to DR VC

connect-viserver DRVC

# Set a host in DR Cluster to add them to.

$esxhost = "DRVSPHERE01"

## Add backto inventory & Change network for VMs

foreach ($row in (Import-Csv c:\Migrate.csv)) {

    $vmName = $row.Name

    $vmxfile = "[$($row.Datastore)] $($vmName)/$($vmName).vmx"

#    $vmlocation = $row.Parent.Split('/')

    $vmNewVM = New-VM -VMFilePath $vmxfile -VMhost $esxhost

    # Move VM to existing folder locaiton

     Move-VM -VM $row.Name -Destination (get-folderbypath $row.Parent)

    # Change Network Portgroup

    $vm = get-vm -Name $row.Name

        Get-NetworkAdapter -VM $vm | Set-NetworkAdapter -NetworkName $row.Network -Confirm:$false

    # Upgrade Virtual Hardware

    Set-VM -VM $vmName -Version v10

    # Update VMware Tools

    update-tools $vmName -Confirm:$false

    start-sleep -s 300

    # Poweron VMs

    Start-VM -VM $vmName -Confirm:$false | wait-tools

    Get-VMQuestion -VM $vmName | Set-VMQuestion –Option "I moved it" -confirm:$false

} ## end foreach

Ben Liebowitz, VCP vExpert 2015, 2016, & 2017 If you found my post helpful, please mark it as helpful or answered to award points.
0 Kudos