When synchronizing files from Windows to Linux systems using common rsync ports like DeltaCopy, cwRsync, or Cygwin, users frequently encounter path length limitations around 255 characters. This stems from legacy MAX_PATH restrictions in Windows APIs and incomplete Unicode handling.
The Cygwin 1.7 test builds (now superseded by newer versions) attempted to address this through better UTF-8 support, but production environments often can't risk unstable builds. Meanwhile, native Windows rsync ports still exhibit these constraints:
# Typical failure example with cwRsync:
rsync -avz /cygdrive/c/long_path/ user@linux:/dest/
rsync: mkstemp "/dest/subdir/This_is_a_very...long_filename.txt" failed: No such file or directory (20)
1. WSL-Based Rsync
Windows Subsystem for Linux provides native rsync with proper long path support:
wsl rsync -avz --no-protect-args '/mnt/c/Users/long_path/' user@linux:/dest/
Note: Use single quotes and /mnt/ paths for Windows drives
2. Robocopy for Windows-to-Linux Transfers
Microsoft's robust copy tool handles long paths when configured properly:
robocopy C:\source\ \\linux-server\share\ /mir /xj /r:1 /w:1 /256 /unilog:transfer.log
Combine with SSH port forwarding:
ssh -L 445:127.0.0.1:445 user@linux
3. SFTP-Based Solutions
WinSCP's robust file transfer engine handles long paths seamlessly:
# WinSCP script example:
option batch abort
option confirm off
open sftp://user:password@linux -hostkey="ssh-rsa 2048 xxxxxxxxxxx"
put -transfer=binary -preservetime -nopermissions "C:\long_path\*" /remote/path/
For environments requiring rsync specifically, consider these tweaks:
- Enable long path support in Windows (requires registry edit and group policy)
- Use \\?\ path prefixes in Windows (limited compatibility)
- Combine 7-zip with SSH for large directory transfers:
7z a -ssw -mx=0 -bd -y archive.7z "long_path" && scp archive.7z user@linux:/dest/
When dealing with millions of files across deep directory structures:
Tool | Files/Min | Path Handling |
---|---|---|
cwRsync | ~5,000 | Fails >255 chars |
WSL rsync | ~45,000 | Full support |
Robocopy | ~65,000 | With /256 flag |
When synchronizing files from Windows to Linux systems using rsync, many developers encounter the infamous 255-character filename limitation. This issue manifests across popular implementations like DeltaCopy, cwrsync, and Cygwin-based rsync solutions. The root cause lies in how these tools handle Windows path conversions before transferring files through SSH tunnels.
The Cygwin 1.7 development branch promises UTF-8 support that may resolve this, but production environments can't risk unstable builds. Let's examine why standard approaches fail:
# Typical rsync command that fails with long paths
rsync -avz -e ssh user@windows-host:/path/ /linux/destination/
# Error: "File name too long (max 255)"
For reliable Windows-to-Linux transfers with long filenames, consider these vetted solutions:
1. Robocopy with SFTP Bridge
Microsoft's robust copy tool handles long paths when configured properly:
robocopy "C:\source" "\\sshfs\user@linux\destination" /E /ZB /COPYALL /R:1 /W:1 /TEE /LOG:transfer.log
# Requires SFTP Net Drive or similar SSHFS implementation
2. WinSCP Advanced Scripting
This GUI tool has powerful scripting capabilities for complex transfers:
# WinSCP script example
option batch abort
option confirm off
open sftp://user:password@linux-host -hostkey="ssh-rsa 2048 xx:xx:xx..."
lcd "C:\long\path\source"
cd /remote/destination
put -filemask="*" -preservetime -transfer=binary
exit
3. rsync via WSL 2
Windows Subsystem for Linux provides native rsync with proper path handling:
wsl rsync -avz --no-perms /mnt/c/source/long_path/ user@remote:/destination/
# Note the /mnt/c/ path conversion for Windows drives
For organizations requiring rsync specifically, this modified build solves path issues:
# Custom rsync build with long path support
rsync -avz --protect-args --iconv=UTF-8,UTF-8 /cygdrive/c/source/ user@host:/target/
# Key parameters:
# --protect-args: Prevents path truncation
# --iconv: Handles character encoding
All solutions maintain SSH compatibility for secure firewall traversal. For high-volume transfers:
- Use compression (-z) when bandwidth is limited
- Implement connection multiplexing in SSH config
- Consider batch processing for millions of files
Example SSH configuration for reliable transfers:
Host linux-host
HostName 192.168.1.100
User transfer-user
Compression yes
ControlMaster auto
ControlPath ~/.ssh/control-%r@%h:%p
ControlPersist 1h
ServerAliveInterval 60