![Rsync 停止工作并返回“rsync 错误:io.c(235) [sender=3.1.2] 处出现无法解释的错误(代码 255)”](https://linux22.com/image/1569713/Rsync%20%E5%81%9C%E6%AD%A2%E5%B7%A5%E4%BD%9C%E5%B9%B6%E8%BF%94%E5%9B%9E%E2%80%9Crsync%20%E9%94%99%E8%AF%AF%EF%BC%9Aio.c(235)%20%5Bsender%3D3.1.2%5D%20%E5%A4%84%E5%87%BA%E7%8E%B0%E6%97%A0%E6%B3%95%E8%A7%A3%E9%87%8A%E7%9A%84%E9%94%99%E8%AF%AF%EF%BC%88%E4%BB%A3%E7%A0%81%20255%EF%BC%89%E2%80%9D.png)
我正在使用 ssh 上的 rsync 从客户端到远程服务器执行备份。
rsync -azLvv --progress -e 'ssh -p22 -vvv' --exclude 'foo' /home/user/ server.tld:Documents/backup/
它已经运行了六个月了,但几天前就停止工作了。
git/myrep.git/refs/heads/something
41 100% 0.08kB/s 0:00:00 (xfr#81, to-chk=36/12092)
debug3: send packet: type 1
Connection reset by A.B.C.D port 22
rsync: connection unexpectedly closed (3211265 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.2]
如果我跳过某些文件(例如 git 存储库),它就可以正常工作。ssh 连接可以正常工作,因为我已从此客户端在此服务器上打开了几天的会话。
客户端上的rsync版本3.1.2,服务器上的版本3.1.1。
答案1
看来问题确实是在同步大文件(约 40GB)时超时。添加 keep alive 选项解决了这个问题。按照这个答案https://serverfault.com/a/818482/399792我添加到 ~/.ssh/config
Host *
ServerAliveInterval 30
ServerAliveCountMax 6
我还添加到 /etc/ssh/sshd_config
ClientAliveInterval 30
ClientAliveCountMax 6