Tuesday, October 28, 2008

HowTo: Setup a Rsync server on Gentoo

I've been invited to write for TuxTraining and help it become a reference for open source users, so this and future posts will most likely be available at TuxTraining.

If you are looking for tutorials, tips and guides covering not only Linux but also BSD and Solaris visit the site. It's updated on a daily basis so I'm sure you'll find it to be very useful.

The goal of this tutorial is to detail the needed steps to setup a general purpose rsync server on Gentoo. Note: this guide doesn't focus on setting up your own Gentoo local rsync mirror, for that please consult Gentoo's official documentation on the matter, namely Gentoo Linux rsync Mirrors Policy and Guide.

rsync is an open source utility that provides fast incremental file transfer, available in multiple platforms such as Linux, *BSD and Solaris.

Let's begin by becoming the superuser, synchronize the portage tree and install rsync:
  • $ su
  • # eix-sync
  • # emerge --ask --tree --verbose net-misc/rsync
Having installed rsync let's add it to the default runlevel so that it automatically starts at boot time:
  • # rc-update add rsync default
Now we move into the rsync server configuration. The rsync server works with modules with are defined in the /etc/rsyncd.conf file. Let's set up a general purpose module:
  • # vim /etc/rsyncd.conf
motd file = /usr/local/etc/rsync.motd
log file = /var/log/rsyncd.log
pid file = /var/log/rsyncd.pid
lock file = /var/log/rsyncd.lock
transfer logging = true
use chroot = yes
path = /home/username
read only = yes
list = yes
comment = Example of a rsync backup module
hosts allow =
It should be noted that a list of modules is returned from a rsync server when the server is queried:
  • $ rsync example.no-ip.org::
backup Example of a rsync backup module
To start the rsync server immediately:
  • $ su
  • # /etc/init.d/rsyncd start
An example of a client side synchronization:
  • $ rsync -av example.no-ip.org::backup/ /destination/
This would recursively transfer all files from the backup module directory on the example.no-ip.org machine into the /destination directory on the local machine. The files are transfered in "archive mode", which ensures that symbolic links, devices, attributes, permissions, ownership, etc are preserved in the transfer. Also, compression is used to reduce the size of data portions of the transfer.

Take a look at the utility's website for ideas on how to use rsync in useful ways.

Additional sources of information:
rsync website
man rsync
man rsyncd.conf


Donnie Berkholz said...

emerge app-admin/gentoo-rsync-mirror

tangram said...

Thanks for the comment Don!

I know about that. The post's purpose was to setup a general purpose rsync server, namely for home network backups.

And for setting up a local Gentoo Rsync server the official documentation is pretty good: http://www.gentoo.org/doc/en/rsync.xml.

Best regards.

tangram said...

I'll update the post to emphasize the general purpose server aspect of the guide.