Download only 'new' or 'modified' files
Hello!
After some great help from you Martin last year I managed to get my scripts working in pipelies in devops (Azure).
However, the downloading\uploading part is taking a loong time when im trying to deploy new versions of my websites.
This is my current script – which is downloading files from a folder on production web app, to a staging slot before swapping the slots.
and for upload:
Is there any way to optimize this?
After some great help from you Martin last year I managed to get my scripts working in pipelies in devops (Azure).
However, the downloading\uploading part is taking a loong time when im trying to deploy new versions of my websites.
This is my current script – which is downloading files from a folder on production web app, to a staging slot before swapping the slots.
$ftp = '$(hostname)' $user = '$(produser)' $pass = '$(prodpass)' $folder = 'site/wwwroot/wwwroot/images/uploaded/*' $sitenameFolder = '$(sitename)' $target = "C:\"+ $sitenameFolder+"\*" Write-Host $target # Load WinSCP .NET assembly Add-Type -Path "$(System.DefaultWorkingDirectory)/drop-yaml/drop-yaml/ftp/WinSCPnet.dll" # Setup session options $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Ftp HostName = $ftp UserName = $user Password = $pass } $session = New-Object WinSCP.Session try { # Connect $session.Open($sessionOptions) # Download files $transferResult = $session.GetFiles($folder, $target) $transferResult.Check() # Print results foreach ($transfer in $transferResult.Transfers) { Write-Host "Download of $transfer succeeded" } } finally { # Disconnect, clean up $session.Dispose() }
$ftp = '$(hostname)' $user = '$(destinationuser)' $pass = '$(desinationpass)' $folder = 'site/wwwroot/wwwroot/images/uploaded/*' $sitenameFolder = '$(sitename)' $fromFolder= "C:\"+ $sitenameFolder+"\*" Write-Host $fromFolder Add-Type -Path "$(System.DefaultWorkingDirectory)/drop-yaml/drop-yaml/ftp/WinSCPnet.dll" $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Ftp HostName = $ftp UserName = $user Password = $pass } $session = New-Object WinSCP.Session try { # Connect $session.Open($sessionOptions) $remotePath = $fromFolder $transferResult = $session.PutFiles(($fromFolder + "*.*"), ($folder + "*.*"), $False) foreach ($transfer in $transferResult.Transfers) { Write-Host "Uploaded of $transfer succeeded" } } finally { # Disconnect, clean up $session.Dispose() }