rsync报错'rejecting excluded file-list'及协议不兼容问题求助
最近我们给2台生产服务器、1台开发服务器(均为Ubuntu 20.04系统)做了更新,另外还有一台仅内网访问的Jenkins构建服务器(Ubuntu 18.04)也同步完成了更新。我们的构建流程是用RSYNC把文件同步到生产/开发服务器的对应目录中。
先说明下,我并不是Linux专家,下面描述的问题和做过的排查,都是靠谷歌搜资料加上自己有限的Linux知识折腾出来的。
我们使用的rsync命令如下:
rsync -rltDv --chmod=ug=rwX,o=rX -e ssh --exclude-from='exclude-list.txt' --delete --filter='protect wordpress/.htaccess' --filter='merge protect-list.txt' ./ jenkins@${WEB_SRV_ADDRESS}:/var/www/test
现在遇到的错误信息:
ERROR: rejecting excluded file-list name: wp-content/plugins/[plugin name]
/[subfolder]/[subfolder]/[subfolder]/.gitkeep
rsync error: protocol incompatibility (code 2) at flist.c(912) [receiver=3.1.3]
目前各服务器的rsync版本情况:
- 生产&开发服务器(Ubuntu 20.04):3.1.3,协议版本31(最新)
- 构建服务器(Ubuntu 18.04):3.1.2,协议版本31(最新)
我已经尝试过以下操作,且每次测试后都将环境恢复到了初始状态:
- 把构建服务器的rsync降级到3.1.1 → 仍报相同错误
- 把生产&开发服务器的rsync降级到3.1.2 → 错误依旧存在
- 恢复构建服务器到更新前的备份状态 → 问题未解决
- 恢复开发服务器到更新前的备份 → 问题居然解决了!但奇怪的是,更新前后rsync的版本完全一致,且我确认这次服务器更新的包中并没有rsync
- 将报错里提到的.gitkeep文件改为php文件 → 出现新错误:
ERROR: rejecting excluded file-list name: wp-content/plugins/[plugin name]/
[subfolder]/[subfolder]/[subfolder]/test.php - 删除报错里的.gitkeep文件 → 错误直接转移到下一个包含.gitkeep的文件夹
我查了不少资料,看到有说法称这个协议错误是因为rsync把错误信息输出到终端,导致终端输出“不干净”才触发的。折腾了两天实在没头绪了,希望有大佬能认出这个问题,或者给我点新的排查思路!
EDIT - exclude-list.txt的内容:
cache/* /.git /.gitkeep /.gitignore /.gitmodules /node_modules /composer.json /composer.lock /Jenkinsfile /gulpfile.js /package.json /package-lock.json /protect-list.txt /vendor /get-composer.sh /exclude-list.txt wordpress@tmp api-v2@tmp /vite.config.js
Update- 补充调试信息:
[receiver] hiding directory folder1/folder2/folder3/folder4/folder5/folder6 because of pattern folder1/folder2/folder3/folder4/folder5/folder6/
[receiver] send_msg(3, 107)
[generator] send_msg(3, 107)
ERROR: rejecting excluded file-list name: folder1/folder2/folder3/folder4/folder5/folder6
备注:内容来源于stack exchange,提问作者Controvi

