This post is very long, so I have broken it down into multiple pages.
Page 1 – Installing rsync daemon on your server
Page 2 – Installing rsync client on your PC
Page 3 – Scheduling rsync automatically
Page 4 – Errors I encountered and their solutions
Download and build rsync from source
- Start a SSH session to your server
- Download the source from samba wget http://samba.anu.edu.au/ftp/rsync/rsync-2.6.9.tar.gz
- Extract the source code gunzip -c rsync-2.6.9.tar.gz | tar x
- Change into the directory so that we can build the software cd rsync-2.6.9
- You will need the GCC compiler installed if you have not already done so.
- Run the auto configure script so that the server can work out if everything necessary is present ./configure –prefix=/usr/mylocal –with-included-popt >log.config 2>err.config
- Check that no errors were logged by the configure script less err.config
- Build the application make >log.make 2>err.make
- Check that no errors were logged during the build process less err.make
- Install the application make install >log.install 2>err.install
- Check that no errors were logged during the installation less err.install
Configure the rsync daemon
We cannot use the default port (873) on Westhost as this is used by Westhost’s own application for nightly backups. Nor can we use ports below 1024 as these require us to run as root. However, ports 8730-8732 are unassigned by IANA (Internet Assigned Numbers Authority), so we can use any of these.
- Create a directory for your configuration files. mkdir /etc/rsyncd
- Create a new configuration file pico /etc/rsyncd.conf. The configuration file consists of a general configuration section which applies to every module and one (or more) modules. Each module starts with its name in square brackets, for example [rsyncd_module].
This sample configuration file will allow upto 3 rsync clients to read the contents of /ftp/pub/rsync PROVIDED that they authenticate themselves by providing the correct credentials AND their IP Address is in the range specified by hosts allow. The connection will close down after 5 minutes (300 seconds) of inactivity.
#Message of the Day
motd file = /etc/rsyncd/rsyncd.motd
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
port = 8730
#Module Options begin here
path = /ftp/pub/rsyncd
comment = My Very Own Rsync Server. This area is ReadOnly
max connections = 3
timeout = 300
uid = myuserid
gid = vuser
read only = yes
list = yes
auth users = rsync_user
secrets file = /etc/rsyncd/secrets
hosts allow = xxx.xxx.xxx.xxx/xx
hosts deny = *
Replace the module name, myuserid, vuser and rsync_user as necessary for your system.
If you want to limit those who have access to your rsync server, then specify the “auth users” and “secrets file”. If you want to restrict where they can access the rsync server from, then you will also need the “hosts allow” and “hosts deny” variables. The value for “hosts allow” should be set to your IP address if you use a static IP (example 10.0.0.1/32) or the range if you use a dynamic IP (example 10.0.0.1/16). Multiple possibilities can be separated by a space. If you don’t understand this bit, then leave “hosts allow” and “hosts deny” out of your configuration for now.
- Create the secrets file pico /etc/rsyncd/secrets. Format is username:password in plain text, one user per line. If you want to communicate over SSH, then ensure that one of the users is your account’s user id; it need not have the same password here as for logging in.
- The secrets file must not be readable by other users, so change the access rights by using the command chmod 600 /etc/rsyncd/secrets
- Create your Message Of the Day file pico /etc/rsyncd/rsyncd.motd. This text will be displayed when a connection is made to your server.