Setting up an rsync server
I’ll describe how to set up an rsync server in Fedora Core. My current installation is on a Fedore Core 8, but the procedure hasn’t changed in a long time.
Rsync is is a protocol and a client/server pair that allows you to rapidly synchronize two file sets. The main use is to create a mirror image of set A onto box B. The neat thing is that it can be configured to skip files that are equal based on check sum, size or timestamp. And if the file is flagged for synchronizing, the rsync protocol copies only the changed bits. This article does not intend to describe the rsync protocol, so I recommend reading one or all of “how rsync works“, “the rsync algorithm” or the wikipedia article on rsync.
Here, we’re going to get a bit more pragmatic <g>
First, rsync is offered as an option when you install your linux box. You can easily check if it’s there:
# rpm -qa|grep rsync rsync-2.6.9-5.fc8
Yep, I’ve got it. If you failed to make the correct selection then, fear not! Simply install it with yum.
yum -y install rsync
The -y switch prevents silly questions.
Now, rsync runs under xinetd, so you’ll need that too.
# rpm -qa | grep xinet xinetd-2.3.14-15.fc8
If nothing, then
yum -y install xinetd
This xinetd/rsync combo means you need to turn on rsync under xinet. Edit /etc/xinetd.d/rsync and make it look like
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no # <== This is what needs to change!!
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
Make sure the firewall doesn’t block the rsync port, per default 873.
If you have a firewall script, add incoming tcp traffic on port 873, or simply edit /etc/sysconfig/iptables and add the line
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT
Restart iptables with
service iptables restart
That’s it. You have an rsync server set up. Albeit not configured. To do that, open /etc/rsyncd.conf and add the folders you want to expose.
Naturally, it’ll look somewhat different for you, but essentially this will work:
uid = nobody gid = nobody use chroot = no max connections = 4 log file = /var/log/rsync.log [pearadio] comment = Podcasts path = /home/jhogstrom/podcasts read only = true dont compress = *.mp3 uid = jhogstrom exclude = .peapod
Test the setup by using the rsync client:
rsync rsync://localhost
The output will look something like
# rsync rsync://localhost pearadio Podcasts
Next time, we’ll discuss rsync clients on windows boxes.
–Jesper Hogstrom