使用Rsync --compare-dest对比远程目录时出现异常错误
Rsync跨Windows(Cygwin)与Ubuntu同步时
--compare-dest参数报错的解决 环境与需求
- 本地:Windows 11 + Cygwin v3.5.3 + Rsync v3.3
- 远程:Ubuntu 22.04 + Rsync v3.2.7
- 核心需求:将本地源目录与远程对比目录的差异,同步至远程目标目录(对比目录、目标目录均位于远程机器)
原命令与问题
执行以下命令时频繁报错:
rsync -aumChqP --modify-window=1 --compare-dest=username@remote-server:/absotute/path/to/compare/remote/dir/ /cygdrive/absotute/path/to/source/local/dir/ username@remote-server:/absotute/path/to/destination/remote/dir/
报错信息:
--compare-dest arg does not exist: username@remote-server:/absotute/path/to/compare/remote/dir
注:该错误并非每次触发,10次尝试中约1次能成功完成对比与同步。
优化后的命令与效果
根据@Philippe的建议,修改--compare-dest参数,去掉远程用户名与服务器地址,直接使用远程机器上的绝对路径:
rsync -aumChqP --modify-window=1 --compare-dest=/absotute/path/to/compare/remote/dir/ /cygdrive/absotute/path/to/source/local/dir/ username@remote-server:/absotute/path/to/destination/remote/dir/
修改后报错情况明显改善。
内容的提问来源于stack exchange,提问作者Shah-G
相关产品推荐
相关产品推荐

