Curated Examples
Synchronize FTP and SFTP directories
Plan, preview, update, and mirror directory trees with Transferetto sync cmdlets.
Use synchronization when a folder transfer should compare both sides before acting. The sync cmdlets can preview planned work, update only missing or changed files, mirror-delete extra destination items, filter paths, and choose how files are compared.
Example
Import-Module Transferetto
$credential = Get-Credential
$sftpClient = Connect-SFTP -Server 'sftp.example.com' -Credential $credential
Sync-SFTPDirectory -SftpClient $sftpClient `
-LocalPath "$PSScriptRoot\Upload" `
-RemotePath '/incoming/releases' `
-Mode Mirror `
-Include '*.zip', '*.json' `
-Exclude 'archive/*' `
-DryRun
Sync-SFTPDirectory -SftpClient $sftpClient `
-LocalPath "$PSScriptRoot\Upload" `
-RemotePath '/incoming/releases' `
-Mode Mirror `
-Include '*.zip', '*.json' `
-Exclude 'archive/*' `
-ShowProgress
Disconnect-SFTP -SftpClient $sftpClient
Useful options
-Direction Uploadtreats the local folder as source.-Direction Downloadtreats the remote folder as source.-Mode Updateleaves extra destination files alone.-Mode Mirrorremoves destination files and folders that are not in the source.-Comparison Size,-Comparison LastWriteTime, and-Comparison SizeOrLastWriteTimecontrol change detection.-DryRunreturns the planned actions without changing local or remote files.