Posh-SSH



  • Hello

    I have the following script, which works correctly, but the source folder is growing exponentially and by having -overwrite, it brings me all the data to SFTP, is it possible to copy incrementally?

    Import-Module posh-ssh
    $ThisSession = New-SFTPSession -ComputerName $SftpIp -Credential $Credential
    Set-SFTPFolder -SessionId ($ThisSession).SessionId -RemotePath $SftpPath -LocalFolder $FilePath -Overwrite
    Get-SFTPSession | % { Remove-SFTPSession -SessionId ($_.SessionId) }



  • I don't believe so because SFTP doesn't handle incremental copies. This is why RSYNC is popular in the UNIX world for exactly this task - because SCP/SFTP don't have a delta protocol built in.



  • For the remote system, is it always creating new files? If so, you could set your script to delete files older than so many days and then run the SFTP?



  • @dafyre said in Posh-SSH:

    For the remote system, is it always creating new files? If so, you could set your script to delete files older than so many days and then run the SFTP?

    Of course, the copy of the content is generated with robocopy incrementally, the whole environment is a Windows, except the SFTP which is a Linux, so in theory I could not make incremental copies to the sftp 😞


Log in to reply