Rsync fails with a network error when running via systemd as root

26 Views Asked by At

Hey the other day I was setting up arch mirror with rsync

[Unit]
Description=Sync repo
Requires=network-online.target

[Service]
ExecStart=/bin/bash /root/sync-repo.sh
User=root
Group=root
Type=oneshot

And When I tried to run it with systemd I got an error

$ systemctl start sync-repo
Job for sync-repo.service failed because the control process exited with error code.
See "systemctl status sync-repo.service" and "journalctl -xeu sync-repo.service" for details.

$ journalctl -fu sync-repo
Mar 30 07:50:23 arch-mirror bash[32312]: rsync error: error in socket IO (code 10) at 
clientserver.c(138) [Receiver=3.2.3]
Mar 30 07:50:23 arch-mirror systemd[1]: sync-repo.service: Main process exited, code=exited, status=10/n/a
Mar 30 07:50:23 arch-mirror systemd[1]: sync-repo.service: Failed with result 'exit-code'.
Mar 30 07:50:23 arch-mirror systemd[1]: Failed to start Rsync backup.
Mar 30 07:56:16 arch-mirror systemd[1]: Starting Sync repo...
Mar 30 07:56:16 arch-mirror bash[34025]: rsync: [Receiver] failed to connect to mirror.23m.com (212.83.32.30): Permission denied (13)

Mar 30 07:56:16 arch-mirror bash[34025]: rsync error: error in socket IO (code 10) at clientserver.c(138) [Receiver=3.2.3]
Mar 30 07:56:16 arch-mirror systemd[1]: sync-repo.service: Main process exited, code=exited, status=10/n/a
Mar 30 07:56:16 arch-mirror systemd[1]: sync-repo.service: Failed with result 'exit-code'.
Mar 30 07:56:16 arch-mirror systemd[1]: Failed to start Sync repo.

However, when trying to run the bash script directly the process completes successfuly.

Os-release: NAME=AlmaLinux Version=9.3

1

There are 1 best solutions below

0
Thebotgame On

In our case we just disabled SELinux and everything work just fine

not the best solution but it works for us

(We don't have anything else that run on that machine only rsync)