Advertisement
jmeg8r

Backup-VDS

May 22nd, 2018
2,363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ?
  2. #Author: James Cruce
  3. #Date: 4/25/2017
  4. #Version: 0.1
  5. #Script has been modified to fit our environment
  6.  
  7.  
  8. #Original Script Source:  http://vcdx56.com/2013/10/backup-vsphere-vnetwork-distributed-switches-using-powercli/
  9.  
  10. # Script to backup the vNetwork Distributed Switches (VDS) including their port groups
  11. # The script will generate:
  12. # * 2 files per VDS, 1 including the VDS configuration without the port groups and 1 including the VDS configuration and the VDS port groups
  13. # * 1 file per VDS port group
  14. #
  15. # The script will run once a day meaning no need to use the force option to overwrite any existing backups since the date is included in the backup file names.
  16. #
  17. # Version 1.0 Magnus Andersson RTS
  18. #????????????????
  19. #
  20. # Start of script parameters section
  21. #
  22.  
  23. # Connect to VIServer first
  24.  
  25. $switches = $null
  26. $date = $null
  27.  
  28.  
  29. $date=get-date -uformat %Y-%m-%d
  30. #
  31. # End of script parameter section
  32. #?????????????? #
  33. # Get the vNetwork Distributed switches
  34. $switches=get-vdswitch
  35. #
  36. # Perform the backups
  37. foreach ($switch in $switches)
  38. {
  39.        
  40.         $DCName = $null
  41.         $DCName = $switch.Datacenter
  42.        
  43.         # Backup each vNetwork Distributed Switch not including the port groups
  44.         export-vdswitch $switch -Withoutportgroups -Description "Backup of $switch without port groups" -Destination "\\uncpath.yourdomain.local\Documentation\VMWare\Switches\$DCName\$switch.without_portgroups.$date.zip" -Force
  45.         #
  46.         # Backup each vNetwork Distributed Switch including the port groups
  47.         Export-VDSwitch $switch -Description "Backup of $switch with port groups" -Destination "\\uncpath.yourdomain.local\Documentation\VMWare\Switches\$DCName\$switch.with_portgroups.$date.zip" -Force
  48.         #
  49.         # Backup each port group individually
  50.         get-vdswitch $switch | Get-VDPortgroup | foreach { export-vdportgroup -vdportgroup $_ -Description "Backup of port group $($_.name)" -destination "\\uncpath.yourdomain.local\Documentation\VMWare\Switches\$DCName\$switch.$($_.name).portgroup.$date.zip" -Force
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement