I prefer to use rsync daemon for all of my rync needs because it provides clean centralized management and saves on system resources. Accordingly, my /etc/rsyncd.conf
contains multiple module entries.
My wrapper scripts for my actual rsync commands are all while
loops that will instantly / repeatedly re-connect rsync in case of dropped connections.
Problem:
The max connections = 1
variable entry for each module is being read globally rather than individually per each module. Thereby causing @ERROR: max connections (1) reached -- try again later
to take place (whichever rsync-daemon connects first gets the single available incorrectly global max connection = 1
, causing all other connections to fail.. annoying ).
Without the max connections = 1
, the while
loop has the ability to spin up unlimited threads and consume unnecessary resources, hence a connections per module limit. Meanwhile the max connections = 1
has the accompanying per module
file.lock per documentation.
This is my /etc/rsyncd.conf
:
[home]
path = /home/username
list = yes
use chroot = false
strict modes = false
uid = root
gid = root
read only = yes
# Data source information
max connections = 1
lock file = /var/run/rsyncd-home.lock
[prod-bkup]
path = /media/username/external/Server-Backups/Prod/today
list = yes
use chroot = false
strict modes = false
uid = root
gid = root
# Don't allow to modify the source files
read only = yes
max connections = 1
lock file = /var/run/rsyncd-prod-bkup.lock
[test-bkup]
path = /media/username/external/Server-Backups/Test/today
list = yes
use chroot = false
strict modes = false
uid = root
gid = root
# Don't allow to modify the source files
read only = yes
max connections = 1
lock file = /var/run/rsyncd-test-bkup.lock
[VminRoot2]
path = /root/VDI-Files
list = yes
use chroot = false
strict modes = false
uid = root
gid = root
# Don't allow to modify the source files
read only = yes
max connections = 1
lock file = /var/run/rsyncd-VminRoot2.lock
This is an example of one of my rsync-daemon wrapper scripts:
#!/bin/sh
#
#
while [ 1 ]
do
cputool --load-limit 7.5 -- nice -n -15 rsync -avxP --no-i-r --rsync-path="rsync" --log-file=/var/log/rsync-home.log --exclude 'snap' --exclude 'lost+found' --exclude=".*" --exclude=".*/" 127.0.0.1::home /media/username/external/home-files-only && sync && echo 3 > /proc/sys/vm/drop_caches
if [ "$?" = "0" ] ; then
echo "rsync completed normally"
exit
else
echo "Rsync failure. Backing off and retrying..."
sleep 10
fi
done
#end of shell script
Question
How can I get rid of the ERROR: max connections (1) reached -- try again later
error?