You should backup your VDS Configs with PowerCLI

So, another vExpert that I follow on twitter (@h0bbel) recently had an issue in his home lab where he cut power to his lab, and his vDS lost all the portgroup names.  Seeing this post made me think, “I should probably backup MY vDS configs too, as my backups were pretty old!

Here are some PowerCLI commands that I found that could help you backup your config!   Also, here is the blog post I used for this script, written by Alan Renouf... AKA PowerCLI Man! (Link)


######################################
#
# PowerCLI script to backup vDS config
# Created by BLiebowitz on 10/22/2015
#
######################################

# Build array for each vCenter with vDS switch
$array = "vc1", "vc2", "vc3", "vc4"
for($count=0;$count -lt $array.length; $count++)

{
# Connect to vCenter
connect-viserver $array[$count]

# Get the name of each vSwitch
$vds = get-vdswitch

# Backup the entire vDS switch
get-vdswitch | export-vdswitch -Description "vCenter 5.5 vDS Switch" -Destination ("c:\VMware\vDS\"+ $array[$count] + "_" + $vds + ".zip") -Force

# Backup each individual Portgroup
Get-vdswitch | Get-vdportgroup | foreach {
Export-vdportgroup -vdportgroup $_ -Description "Backup of $($_.Name) PG" -Destination ("c:\VMware\vDS\" + $array[$count] + "\$($_.Name).zip") -Force
}
# Disconnect from vCenter
disconnect-viserver $array[$count] -confirm:$false
}
# Rinse and Repeat

Backup your vDS configs TODAY!  Smile

– Ben Liebowitz, VCP, vExpert
NJ VMUG Leader

Share This:

One thought on “You should backup your VDS Configs with PowerCLI

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.