大网数据广告活动
服务器运维问答

rsync - unexplained error

· 52CE 我爱测

I'm using a script like that: rsync -avu --delete --progress user@host:~/backup . and every time, after a while, a receive this error: rsync: connection unexpectedly closed (10251754 bytes received so far) [receiver] rsync error:…

问题原文

原帖链接 · Andrej Pandovich · CC BY-SA 3.0

I'm using a script like that:

rsync -avu --delete --progress user@host:~/backup .

and every time, after a while, a receive this error:

rsync: connection unexpectedly closed (10251754 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [receiver=3.1.0]
rsync: connection unexpectedly closed (45482 bytes received so far)  [generator]
rsync error: unexplained error (code 255) at io.c(226) [generator=3.1.0]

# generator = Debian 5, rsync  version 3.0.3  protocol version 30 (Generator[A])
# receiver = Ubuntu 14.04, rsync  version 3.1.0  protocol version 31 (Receiver[A])

I have over ten years of experience in rsync, I tried everything, but I can't figure out why it happens.

On both sides: I have no errors in logs, no strange things in tcpdump, no connection problems, no firewalls. The transfer just suddently stops after sometime.

The problem is not limited to one server.

I thought it could be a some king of incompatibility between rsync versions, so I switch the generator with a fresh new server (Debian 8) on a completely different server farm and I have update rsync on the receiver, but I get this error:

rsync: connection unexpectedly closed (31931964 bytes received so far) [receiver]
rsync: [generator] write error: Broken pipe (32)
rsync error: unexplained error (code 255) at io.c(820) [generator=3.1.2]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [receiver=3.1.2]

# generator = Debian 8, rsync  version 3.1.1  protocol version 31 (Generator[B])
# receiver = Ubuntu 14.04, rsync  version 3.1.2  protocol version 31 (Receiver[B])

Then I tried to sync Receiver[A] with Generator[B] throught a proxy and it works

Receiver[A](Italy) <=> HTTP Proxy(Paris) <=>  Generator[B](Strasbourg)

So now I have

Receiver[A] <=> Generator[A] // ERROR
Receiver[A] <=> Generator[B] // ERROR   
Receiver[B] <=> Generator[B] // ERROR

Receiver[A] <=> HTTP Proxy <=> Generator[A] // OK
Receiver[A] <=> HTTP Proxy <=> Generator[B] // OK  

I tried too without HTTP Proxy

Receiver[A] <=> Generator[C] // OK
Receiver[A] <=> Generator[D] // OK  
Receiver[A] <=> Generator[E] // ERROR

where generators [C], [D] and [E] are servers in Paris (same server farm of my HTTP Proxy) with rsync 3.0.9, prot. v. 30.

So the bottom line here is: I have multiple servers in multiple locations. On Receiver[A] I have no firewall and things works well since few days ago. Now rsync return unexplained error and I can't figure out why.

I think it's a some king of phisical network error (not on my machines), but I don't know if I can find, isolate and reproduce this error.

Thanks for your help!

社区高分解答

原帖链接 · chutz · CC BY-SA 4.0

It seems that you are having a hard time pinpointing the issue but no problems reproducing it. In this case, it may help if you troubleshoot the SSH connection itself, and also the data that you are getting over it.

You can run your rsync command like below, it would produce some data dumps:

rsync -e 'bash -x -c "ssh -vvvv $0 $@ 2>/tmp/rsync-ssh.stderr | tee /tmp/rsync.stdout"' -avu --delete --progress user@host:~/backup .

Looking at the end of those files might have something useful. E.g., if the SSH connections was interrupted, something should show up in /tmp/rsync-ssh.stderr. And if it is actually a problem on the other side, the actual rsync protocol dump in /tmp/rsync.stdout may have some stringified hint (strings /tmp/rsync.stdout).

If I had to take a guess, it is either a nasty firewall or a physical issue corrupting packets causing the SSH connection to drop.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-11-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。