Thursday, January 31, 2013

rsync server daemon on Mac OS X with launchctl

There are many web pages describing how to enable the rsync daemon on Mac OS X using launchd/launchctl mechanism. But I had to use a different (and simpler) plist file in LaunchDaemons to make it work across reboots on Lion (10.7.4).

(I started by following this guide , and this very similar one. And I also read this and this. In the end, what helped me getting the plist file right was this thread. Particularly this post: "For one you have both a Program and a ProgramArguments key, when you should have only one or the other (you use Program if there is just one element to the command, or ProgramArguments if there are multiple." And this one.)

This is the .plist file I used in /Library/LaunchDaemons/org.samba.rsync.plist : 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

This is an example /etc/rsyncd.conf file:

secrets file = /etc/rsyncd.secrets
hosts allow = *.cust.isp.tld

pid file = /var/run/
uid = nobody
gid = nobody
list = yes
read only = yes

path = /Users/Shared
comment = Users-Shared
uid = someuser
gid = admin
auth users = user_in_secrets

The file /etc/rsyncd.secrets looks like:


To install it:

sudo -s
chown root:wheel /etc/rsyncd.*
chmod 644 /etc/rsyncd.conf
chmod 600 /etc/rsyncd.secrets
launchctl load /Library/LaunchDaemons/org.samba.rsync.plist
launchctl start org.samba.rsync ## (this last command is probably unneeded)

To check if it is installed and running:

launchctl list | grep rsync
808  -    0x7fddb4806c10.anonymous.rsync
-    0    org.samba.rsync

ps ax | grep [r]sync
  808   ??  Ss     0:00.00 /usr/bin/rsync --daemon

rsync --stats someuser@localhost::

To remove it:

sudo launchctl unload /Library/LaunchDaemons/org.samba.rsync.plist
sudo killall rsync

For logging transfers, add

log file = /var/log/rsyncd.log
transfer logging = yes

to /etc/rsyncd.conf. And to have the log rotated, create a file like /etc/newsyslog.d/rsyncd.conf and add

# logfilename          [owner:group]    mode count size when  flags [/pid_file] [sig_num]
/var/log/rsyncd.log   644  5    5000 *     J


Labels: , , ,


Blogger MenacingM said...

Very helpful, thanks. Small error as well:

launchctl start org.samba.rsync.plist

should be:

launchctl start org.samba.rsync

27 August, 2013 03:07  
Anonymous Daniel said...

Also: the rsyncd.secrets - file is set to /etc/rsync/rsyncd.secrets in the rsyncd.conf, but later and in the text you refer to /etc/rsyncd.secrets .

Thank you, otherwise everything worked like a charm!

Thanks for writing it out so clearly!

16 September, 2013 03:57  
Blogger Øystein Nytrø said...

Your setup, with modificatons, perfectly until I updated to Maverick.
No amount of tweaking will make it run now.

15 December, 2013 01:35  
Blogger Milivoj. said...

@MenacingM, @Daniel: Thanks! Corrected.

@Øystein Nytrø: I just installed it on Mavericks, and it seems to run fine. It was a fresh install of OS X, not an upgrade. So I'm afraid I don't know what went wrong with your setup.

23 June, 2014 19:40  

Post a Comment

Links to this post:

Create a Link

<< Home