After system reboot rsync starts but no lock file is created, therefore when rsync on a remote machine tries to get a directory for backup it fails with

@ERROR: failed to open lock file
rsync error: error starting client-server protocol (code 5) at main.c(1534) [Receiver=3.0.9]

When restarted by hand the lock file is successfully created and the problem goes away until the next reboot of the server/source.

Rsyncd is started from /etc/rc.local:

/usr/bin/rsync --daemon --config /etc/rsyncd/rsyncd.conf

There is nothing particularly interesting in logs. Here's /var/log/rsyncd.log:

2016/04/28 06:23:34 [26273] connect from <remote client> (<remote ip>)
2016/04/28 06:23:34 [26273] rsync: failed to open lock file /var/lock/rsyncd: Permission denied (13)

And the rsyncd config:

# cat /etc/rsyncd/rsyncd.conf
log file=/var/log/rsyncd.log
use chroot = yes
max connections=3
lock file = /var/lock/rsyncd
list = yes
uid = root
gid = root
secrets file = /etc/rsyncd.secrets
strict modes = yes
ignore errors = no
ignore nonreadable = yes
transfer logging = no 
timeout = 600
refuse options = checksum dry-run
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz

[backup dir config]

The system on the server host is CentOS (not sure about the version as it shows RedHat release number):

# cat /etc/centos-release 
Red Hat Enterprise Linux AS release 4 (Nahant Update 5)
# uname -a
Linux <hostname> 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

rsync is:

# yum info rsync
Installed Packages
Name        : rsync
Arch        : x86_64
Version     : 3.0.6
Release     : 12.el6

What could be the reason for this behavior?

UPD: tried starting rsyncd with xinetd and init script, in both cases behavior was the same as described earlier. When started with xinetd lock creation failed in any case with denied permission; same for init script when starting on boot - doing 'service rsync restart' manually makes the problem go away.


Got help on CentOS forums and solved the problem. It was SELinux permissions issue, wrong context for rsync executable or somesuch. I did several things, the one that worked was updating policy packages.

In the order I tried it:

Create a separate directory for lock file, restore defaults on it and fix config to use the new path

# mkdir /var/lock/rsync
# chmod 755 /var/lock/rsync
# restorecon -r /var/lock/rsync

# vim /etc/rsyncd/rsyncd.conf
lock file = /var/lock/rsync/rsyncd

Update packages:

# yum update selinux-policy selinux-policy-targeted

There is some info in man rsync_selinux from the selinux-policy-doc package.

There was one more suggestion which I didn't try as the problem has been solved by this point:

# getsebool rsync_server
rsync_server --> off

# setsebool -P rsync_server on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.