From 33e41a756ebc22f2bd1a692176134846d60725cf Mon Sep 17 00:00:00 2001 From: Brian Wuchner Date: Tue, 11 Jan 2022 20:25:22 -0500 Subject: [PATCH] Update Backup-VCSA.psm1 Fixes #468. In this issue, it is noted that starting with vSphere 7 you need to use SFTP instead of SCP when calling Backup-VCSAToFile. In this commit we are adding SFTP to the Validate Set for the Location Type. Additionally, we add some logic to toggle between SFTP or SCP depending on appliance version and provide warning text that an adjustment was made. Signed-off-by: Brian Wuchner --- Modules/Backup-VCSA/Backup-VCSA.psm1 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Modules/Backup-VCSA/Backup-VCSA.psm1 b/Modules/Backup-VCSA/Backup-VCSA.psm1 index c444e10..d0753d1 100644 --- a/Modules/Backup-VCSA/Backup-VCSA.psm1 +++ b/Modules/Backup-VCSA/Backup-VCSA.psm1 @@ -43,7 +43,7 @@ Function Backup-VCSAToFile { [switch]$FullBackup, [Parameter(ParameterSetName='CommonBackup')] [switch]$CommonBackup, - [ValidateSet('FTPS', 'HTTP', 'SCP', 'HTTPS', 'FTP', 'SMB')] + [ValidateSet('FTPS', 'HTTP', 'SCP', 'HTTPS', 'FTP', 'SMB', 'SFTP')] $LocationType = "FTP", $Location, $LocationUser, @@ -71,6 +71,17 @@ Function Backup-VCSAToFile { } if ($FullBackup) {$parts = @("common","seat")} if ($CommonBackup) {$parts = @("common")} + + # Per github issue 468 (https://github.com/vmware/PowerCLI-Example-Scripts/issues/468) adding some logic to account for SFTP/SCP handling in versions after VC 7.0. + $vCenterVersionNumber = (Get-CisService -Name 'com.vmware.appliance.system.version').get().version + if ( ($vCenterVersionNumber -ge 6.5 -AND $vCenterVersionNumber -lt 7.0 ) -AND $LocationType -eq 'SFTP' ) { + write-warning 'VCSA Backup for versions 6.5 and 6.7 use SCP, not SFTP. Adjusting the LocationType accordingly.' + $LocationType = 'SCP' + } + if ( $vCenterVersionNumber -ge 7.0 -AND $LocationType -eq 'SCP' ) { + write-warning 'VCSA Backup starting with version 7.0 use SFTP and not SCP. Adjusting the LocationType accordingly.' + $LocationType = 'SFTP' + } } Process{ $BackupAPI = Get-CisService 'com.vmware.appliance.recovery.backup.job'