rsync - 无法解释的错误

And*_*ich 5 networking ssh rsync

我正在使用这样的脚本:

rsync -avu --delete --progress user@host:~/backup .
Run Code Online (Sandbox Code Playgroud)

每次过一段时间后,都会收到此错误:

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])
Run Code Online (Sandbox Code Playgroud)

我有十多年的经验rsync,我尝试了所有方法,但我无法弄清楚为什么会发生这种情况。

双方:我在日志中没有错误,在 tcpdump 中没有奇怪的东西,没有连接问题,没有防火墙。传输只是在一段时间后突然停止。

问题不仅限于一台服务器

我认为这可能是 rsync 版本之间不兼容的原因,所以我在完全不同的服务器场上用全新的服务器(Debian 8)切换生成器,并且我在接收器上更新了 rsync,但是我收到了这个错误:

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])
Run Code Online (Sandbox Code Playgroud)

然后我尝试通过代理将 Receiver[A] 与 Generator[B] 同步并且它工作正常

Receiver[A](Italy) <=> HTTP Proxy(Paris) <=>  Generator[B](Strasbourg)
Run Code Online (Sandbox Code Playgroud)

所以现在我有

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  
Run Code Online (Sandbox Code Playgroud)

我也试过没有 HTTP 代理

Receiver[A] <=> Generator[C] // OK
Receiver[A] <=> Generator[D] // OK  
Receiver[A] <=> Generator[E] // ERROR
Run Code Online (Sandbox Code Playgroud)

生成器在哪里[C][D]并且[E]是巴黎的服务器(我的同一个服务器场HTTP Proxy)与rsync 3.0.9, prot. v. 30.

所以这里的底线是:我在多个位置有多个服务器。在Receiver[A]我没有防火墙和东西效果很好,因为前几天。现在rsync回来unexplained error,我不知道为什么。

我认为这是一个物理网络错误之王(不是在我的机器上),但我不知道我是否能找到、隔离和重现这个错误。

谢谢你的帮助!

chu*_*utz 4

您似乎很难查明问题,但重现问题没有问题。在这种情况下,如果您对 SSH 连接本身以及通过它获取的数据进行故障排除,可能会有所帮助。

您可以像下面一样运行rsync命令,它会生成一些数据转储:

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

查看这些文件的末尾可能会有一些有用的东西。例如,如果 SSH 连接中断,则/tmp/rsync-ssh.stderr. 如果实际上是另一方的问题,则实际的 rsync 协议转储/tmp/rsync.stdout可能有一些字符串化提示(strings /tmp/rsync.stdout )。

如果我不得不猜测的话,要么是令人讨厌的防火墙,要么是物理问题损坏了数据包,导致 SSH 连接断开。