Dienstag, Juli 29, 2008

Activating the rsync daemon on a QNAP TS-101 NAS

Update: standard rsync seems to be supported without any manual modification since firmware version 2.3.0. Just switch on "Allow remote Rsync server to back up data to NAS" which can be found under "SystemTools" > "Remote Replication". Thanks to seye for this hint.

Got a little new device in my tech zoo. It's a QNAP NAS Server, the TS-101. Nifty little thing because it can act as a multimedia streamer (for iTunes and UPnP clients - uses Twonky inside for the latter), backup storage (works even with Apple's Time Machine if you don't mind hacking a little bit), web server, download agent, etc. pp.

What annoyed me was, that even with the latest firmware one cannot use rsync directly to backup files. In fact there is an rsync daemon running on the TS-101 but it is solely used by QNAP to sync between their NAS devices. If you try to connect to it, you'll probably get an authentication error.

What actually is activated with the latest firmware is telnet access. So here we go. :-)

Looking at the processes running on the TS-101 ("ps | grep rsync") one can see an rsync daemon ("/usr/bin/rsync --daemon --sever-mode=1"). Never saw the --server-mode option before and the man pages on my Mac do not list it either. So let's do "rsync --daemon --help" on the TS-101 which yields:

--sever-mode=mode 0:Normal, 1:QNAP in daemon-mode

Aha! Kill the old daemon, launch a new one in server-mode 0 ("/usr/bin/rsync --daemon --sever-mode=0") and try to connect from the Mac:

@ERROR: invalid uid admin

Bummer. Hmmm. An rsync daemon gets it's configuration from a file named rsyncd.conf. On the TS-101 it is located in /etc/conf. The first lines look like this:

uid = admin
gid = administrators
log file = /var/log/rsyncd.log

Strangely the official man page for the rsyncd.conf file does not mention setting uid and gid outside of the modules (do "man rsyncd.conf" on a Unix system). But it seems clear to me that this uid/gid should at least exist on the system - which is not the case on a brand new TS-101.

So one could probably create an account named admin. I just edited the rsyncd.conf and changed admin to administrator (the latter uid does exist).

Now it works!

(Note: No need to reboot the TS-101, because rsync reads its config file every time a connection attempt is made.)

So finally we can make backups between a machine with an rsync client and the rsync daemon on the TS-101 (without using an ssh tunnel which is another possibility that is slower and IMHO not necessary in home networks).

What remains open?
  • After rebooting the TS-101 the rsync daemon is running in mode 1 again. Found the place to change this (/etc/init.d/rsyncd.sh) permanently but
  • It seems that the files underneath /etc get overwitten which the original ones from time to time. Didn't investigate this though...
  • Why does QNAP use a special private mode with rsync? Prevents the normal use and I cannot think of a need for a special mode because the orginal rsync is so versatile)
(Note for Mac users: the latest rsync 3.0.3 can cope with all HFS+ metadata)