• Paul Kennard

Part 2: Distributed Switch Backup & Recovery – Essentials

This is the second part in an ongoing ITBOD365 Essentials series, with this one focusing on the VMware Distributed Switch.

The vDS has been around for a while now and offers many benefits over the standard switch with the many features and complexity that can be configured, including its flexibility and integration with other products such as NSX the vDS soon becomes an item that you need to consider.

However, way too often this is not the case, so this post will cover this subject off to provide you with a good backup and recovery procedure for the vDS but also a solid rollback as a part of any change process affecting the vDS.

If you would like to jump to the other parts, you can use the links below:

Part 1: vCenter Backup & Recovery

Part 2: Distributed Switch Backup & Recovery

Part 3: ESXi Host Backup & Recovery

Distributed Switch Backup

The option to back up and export your vDS configurations VMware introduced way back in Web Client in 5.1, in this post I will cover how to carry out the export via both the Web Client and PowerCLI which is the most flexible and fastest way to carry out each whilst also opening up opportunities towards automation.

vDS Backup Web Client

1. Login to the vSphere client

2. Select the vDS you wish to backup and Right Click

3. Navigate to Settings > Export Configuration

4. Enter the description for backup and click OK

5. Save file by clicking OK and rename for easier identification.

That’s it, you now have the configuration exported for that vDS, however, please note you will need to carry this out on each vDS that needs backing up. 

The GUI exports are good for ad hoc type backups for things like a point in time recovery to cover planned environmental changes as part of a change rollback, but my preferred method is to use PowerCLI and capture all vDS configs in one go with one command which I will cover next.

vDS Backup PowerCLI

This method is by far the easiest way to get a full configuration export of all the Distributed Switches within your environment and is the perfect opportunity to automate this and include them as part of your normal backup process.

1. Ensure you have a directory/share available to store your vDS backups. I have just created a local Dir for this demonstration.

2. Open PowerShell

3. Fill in the details highlighted below, copy/paste into PowerShell prompt run and enter your vCenter credentials when presented.

Connect-VIServer $DestinationVC -Credential (Get-Credential)
$DestinationVC =Your-VC-FQDN.local
$vDSDetails = Get-VDSwitch
$vDSNames = $vDSDetails.Name
$datestamp = Get-Date -Format “dd-MM-yyyy”
Foreach ($vDSName in $vDSNames)
$DestiationDir =d:\Your-Export-Dir\+ $datestamp + “\” + $vDSName + “\”
New-Item -Path $DestiationDir -ItemType “Directory” -Force
$filename= $DestiationDir + $vDSName”
Get-VDSwitch -Name $vDSName | Export-VDSwitch -Description “vDS Backup” -Destination $filename
Disconnect-VIServer -Server $DestinationVC -Confirm:$false

4. All done easy-peasy, you will now see in your location specified a nicely organised set of backups of all your vDS configurations within a dated folder.

Distributed Switch Restore

What's The Damage?

Just for testing's sake and to show both Web Client and PowerCLI restores let make some undesired changes.

Distributed Switch Restore Web Client

Ok let's start via the GUI to restore the changes made to “ITBOD365-DSwitch” where 2 port groups were "accidentally" deleted, and I renamed another to “WHAT A vPICKLE”.

1. Login to the vSphere client

2. Select the vDS you wish to restore and Right Click

3. Navigate to Settings > Restore Configuration

4. Click Browse and navigate and select the vDS configuration backup file, then click Next

5. Review the summary and click Finish

After the task has completed, you now see that vDS back to normal and deleted and re-named port groups have reverted.

If however you need to recover the whole Distributed Switch via the Web Client, you would follow the same process but at the Datacenter level.

Distributed Switch Restore PowerCLI

Finally, the last vDS recovery I will use PowerCLI.

1. Open PowerShell

2. Fill in the details highlighted below, copy/paste into PowerShell prompt and run, and enter your vCenter credentials.

Connect-VIServer $DestinationVC -Credential (Get-Credential)
$DestinationVC =Your-VC-FQDN.local
New-VDSwitch -BackupPath d:\ -Location Your-Datacenter-Name -KeepIdentifiers:$true

3. Press Enter to start and then wait for task to complete

This concludes the Distributed Switch backup and restores post, in the next Part 3 in the series I plan to cover how to back up and restore your ESXi host configuration so hope you return and wish you all the best.


Cloud & Virtualization Blog by ITBOD - paul kennard