Re: You were correct Martin (big surprise ;-) )
Thanks for sharing this.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Compression
was set to 0. The changes have worked (I also added in SFTPDownloadQueue
at 128) – I think I didn't see the impact of the changes as I was using the wrong code version (the one with Compression
off).
$F25sessionOptions.AddRawSettings("Compression", "1")
$F25sessionOptions.AddRawSettings("CacheDirectories", "0")
$F25sessionOptions.AddRawSettings("CacheDirectoryChanges", "0")
$F25sessionOptions.AddRawSettings("SFTPDownloadQueue", "128")
$F25sessionOptions.AddRawSettings("Cipher", "arcfour,blowfish,aes,3des,chacha20,WARN,des")
$F25sessionOptions.AddRawSettings("PreserveDirectoryChanges", "0")
$F25sessionOptions.AddRawSettings("SendBuf", "0")
$F25sessionOptions.AddRawSettings("SshSimple", "0")
The directory cache is updated whenever you perform any operation on the directory, like file transfer.
The cache is enabled by default and can be disabled by unticking the Cache directory changes checkbox. The cache can be permanent (enabled by default), i.e. preserved between sessions. It is stored into configuration storage.
SFTPDownloadQueue
setting to 64, but it didn't speed it up – in fact, the download took 50 minutes so I removed that and will have to be happy at 11 minutes with the existing code unless there is a clear problem with my end of the configuration. :)
$F25sessionOptions.AddRawSettings("Compression", "1")
$F25sessionOptions.AddRawSettings("CacheDirectories", "0")
$F25sessionOptions.AddRawSettings("CacheDirectoryChanges", "0")
-rawsettings
and implement some of the suggested solutions (most notably trying Blowfish and Sendbuf=0
). Our run of this code was also in the 40 minute range. The network team here worked with me to do a test from the same machine internally to one of their externally hosted (over the internet like our vendor) sites and we achieved ~20MB/sec in our test.
Import-Module WinSCP
$PDPRunType = "DAILY" # Added just for testing purposes
$TodayDateString = Get-Date -Format "yyyyMMddhhmmss"
$TodayDateShortStr = Get-Date -Format "yyyyMMdd"
$PDPRootDir = "C:\Projects\PullDailyPDP"
$WinSCPBinPath = "$PDPRootDir\Bin\WinSCP.exe"
$SessionLog = "$LogDir\WinSCP_Session_$TodayDateString.txt"
$DebugLog = "$LogDir\WinSCP_Debug_$TodayDateString.txt"
$PMONDIRNAME = "PMONDIR"
$F25UN = "UserName"
$F25FingerPrint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
$F25Site = "sftpSite.com"
$F25PWSecure = Get-Content "C:\Projects\Credentials\VendorPull25.txt" | ConvertTo-SecureString
$F25BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($F25PWSecure)
$F25PW = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($F25BSTR)
$TimeOutMin = 10
$TimeOutMinTS = New-Timespan -Minutes $TimeOutMin
## Set Up for Test
$F25PullDir = "/USER/UserPath/PRIME/DAILY3I010"
$BackupDirRoot = "E:\Backup\Daily"
$DailyPDPDir = "E:\Prime\Daily"
$LocalPMonFile = "$TodaysBkpDir\$PMONDIRNAME"
$TodaysBkpDir = "$BackupDirRoot\$TodayDateShortStr"
#
# Set up WinSCP Options
#
$F25session = New-Object WinSCP.Session
$F25sessionOptions = New-Object WinSCP.SessionOptions
$F25transferOptions = New-Object WinSCP.TransferOptions
#
# WinSCP Session and Transfer Options
#
$F25session.ExecutablePath = $WinSCPBinPath
$F25Session.DebugLogPath = $DebugLog
$F25Session.SessionLogPath = $SessionLog
$F25transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$F25sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$F25sessionOptions.HostName = $F25Site
$F25sessionOptions.UserName = $F25UN
$F25sessionOptions.Password = $F25PW
$F25sessionOptions.SshHostKeyFingerprint = $F25FingerPrint
$F25sessionOptions.Timeout = $TimeOutMinTS
#
# Raw settings to speed download MB/s
#
$F25sessionOptions.AddRawSettings("Cipher", "blowfish,aes,chacha20,aesgcm,3des,WARN,des,arcfour")
$F25sessionOptions.AddRawSettings("PreserveDirectoryChanges", "0")
$F25sessionOptions.AddRawSettings("SendBuf", "0")
$F25sessionOptions.AddRawSettings("SshSimple", "0")
$F25session.Open($F25sessionOptions)
$Files2Pull = Get-Content -Path $LocalPMonFile
If ($F25Session.Opened)
{
Foreach ($FileName in $Files2Pull)
{
$FileName = $FileName.Trim()
$RemoteFile = "$F25PullDir/$FileName"
$PullResult = Receive-WinSCPItem -WinSCPSession $F25Session -Path $RemoteFile -Destination $TodaysBkpDir -Remove
}
}