Backups: error in rsync protocol data stream (code 12)

I’m scratching my head here: I’m trying to get rsync backups configured from my box to my home synology over tailscale. I can rsync files over via the command line fine:

sudo rsync -a -e "ssh -i /root/.ssh/id_rsa_miab -p 31422" *.md box@202.114.171.94:/var/services/homes/box/backup/

but when Mail-in-a-box tries, this the error:

Dec 15 10:52:37 box start[87821]: Giving up after 5 attempts. BackendException: Error running 'rsync -e 'ssh -p 31422 -oBatchMode=yes '-i /root/.ssh/id_rsa_miab -p 31422'' '-e "/usr/bin/ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p 31422 -i /root/.ssh/id_rsa_miab"' box@202.114.171.94:backups/': returned 12, with output:
Dec 15 10:52:37 box start[87821]: rsync: [sender] Failed to exec /usr/bin/ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p 31422 -i /root/.ssh/id_rsa_miab: No such file or directory (2)
Dec 15 10:52:37 box start[87821]: rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.2.7]
Dec 15 10:52:37 box start[87821]: rsync: connection unexpectedly closed (0 bytes received so far) [sender]
Dec 15 10:52:37 box start[87821]: rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7]

I’m baffled!

I have this exact setup and it worked for me out of the box.

I setup a local user on synology which is only allowed to connect with a public key. Gave access to the synology folder for the user where i want to store the backup.
Enabled and changed the default ports for rsync.
Allowed the ip of my box to go through firewall for the rsync port.
Tested rsync from the command line
Completed the backup section of miab.

This has been working fine for almost 12 months now.

Dont know why it fails for you unless you missed so something in the above steps.

Since 2 days I have the exact same error. I have not changed anything to my setup which has been working fine for the last 12 months. Only thing that happened is the usual package updates.
Something recent broke this functionality but I don’t know what…

rsync error: error in rsync protocol data stream (code 12) at io.c(231) [Receiver=3.2.7]

This issue might be due to something that has changed on the synology side of things. I found this synology forum topic, you might want to look over to see if it helps: https://community.synology.com/enu/forum/1/post/144850

1 Like

Thanks for that. I will look into the thread a bit more. I was not looking at Synology as the culprit due to my testing,

I spun up a proxmox lxc locally to do some rsync testing.

I was able to rsync from the lxc container to synology using the public ip.
I was not able to rsync from miab to synology or the lxc container.

Therefore i discarded synology or my unifi firewall as possible root causes.

I did some more testing and there is an issue to reach the synology nas

root@box:~/.ssh# ssh-copy-id rsync@my_ip
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/root/.ssh/id_rsa.pub”
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: ERROR: ssh: connect to host my_ip port 22: Connection timed out

When I run the same command from the lxc container i works so I tried to ping my ip and this times out.
I can ping 1.1.1.1 just fine

What could be the reason that the miab box can not ping my ip? I can ping it fine from my phone or laptop…

root@box:~/.ssh# ping my_ip
PING my_ip (my_ip) 56(84) bytes of data.
^Z
[6]+ Stopped ping my_ip
root@box:~/.ssh# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=58 time=10.2 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=58 time=10.1 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=58 time=10.0 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=58 time=9.99 ms
64 bytes from 1.1.1.1: icmp_seq=5 ttl=58 time=10.0 ms
^Z
[7]+ Stopped ping 1.1.1.1

I don’t know enough about your environments to speculate, but, for example, my home IP cannot be pinged because my firewall is configured not to respond to pings from external addresses. I’m not saying that’s your problem, but it appears that you have a firewall blocking access.

I know this doesn’t help solve your current issue, but I actually do my backups in the other direction, meaning, I have a cron job running on my personal Linux system that does a nightly rsync to the MiaB server to pull the backups, rather than having my MiaB server try to push the backups through my home firewall. If you can’t get to the bottom of this, you might try that instead.

1 Like

I will look into the pull suggestion but the issue is not that my firewall does not react to pings. I can ping my ip fine from my iPhone on a 4G connection. Two things I can think off

  • miab can not ping my ip for some reason.
  • my firewall is blocking the miab ip for some reason

I have no clue on how to investigate the first option which seems unlikely. The 2nd option seems more likely as I did install an update for my Unifi Dreammachine in the same timeframe.

Update: I can not figure out why miab has an issue with my home IP… Therefore I implemented the suggestion from @dms. I am now pulling the backup from miab to my Synology NAS with rsync. Technically speaking the Proxmox linux container is doing the pulling and storing it on a Synology folder that I mapped. End result is the same I had before so happy with the solution. Thanks again for the suggestion.

This approach is actually much safer because I don’t need to turn on rsync on the synology and punch a hole in my firewall.

As the original poster, I thought I should add here that I too have abandoned pushing backups to the Synology, and instead pulling from the Synology as @eXTric suggested.

The easiest way to backup to a synology NAS is to use “Active Backup for Business”
You just configure a “File Server” that connects via the public key and create a daily task.