Achieve faster file transfer times by running Rsync as a daemon

When syncing files over a trusted network, where speed matters more than someone's ability to see contents of the transfer, might want to run rsync as a daemon instead of using remote shell as the transport.

In my tests, running rsync as a daemon produces file transfers almost twice as fast as when rsyncing over SSH.

Rsync daemon can be run either on the box that's sending data or receiving it. In this example, the box receiving data will run the rsync daemon -- so we'll be using rsync in push mode ("client" pushing to "server"). I suppose, the other way around (pull mode), could be considered more secure since the rsync module can be setup in read only mode.

NOTE: the following setup should work on any Linux, but in my case the server was Debian 5.0.3 and client was Ubuntu 8.10.

On the server:

1. Create /etc/rsyncd.conf containing:

1
2
3
4
5
6
7
8
9
10
11
uid = root
gid = root
max connections = 5
hosts allow = 192.168.1.5 192.168.1.77
socket options = SO_KEEPALIVE
 
[modulename]
path = /path/to/dir
auth users = someuser
read only = no
secrets file = /etc/rsyncd.passwd

2. Create secrets file /etc/rsyncd.passwd containing:

1
someuser:somepass

3. Debian rsync daemon startup script will complain if secrets file is world readable so we set perms so it isn't:

chmod 640 /etc/rsyncd.passwd

4. Start up the daemon:

/etc/init.d/rsync start

NOTE: any time /etc/rsyncd.conf is modified, daemon will need to be restarted.

On the client:

By default, rsync daemon on the server will prompt for password. You could supply a password file to suppress the prompt.

1. Create secrets file /etc/rsyncc.passwd containing:

1
somepass

2. Invoke rsync with:

rsync --password-file=/etc/rsyncc.passwd --progress -rh /path/to/local/dir/ someuser@server::modulename/path/to/remote/dir/

The above will read password on the client from /etc/rsyncc.passwd and sync contents of /path/to/local/dir/ on the client to /path/to/dir/path/to/remote/dir/ on the server (modulename expands to path in /etc/rsyncd.conf on the server).

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).