# Rsync daemon



## dennylin93 (May 16, 2009)

Right now I'm running using rsync for server backups. I'm wondering whether I should use daemon mode for rsync. Are there any differences in performance?


----------



## vivek (May 16, 2009)

In daemon mode, rsync listens to the default TCP port of 873, serving files in the native rsync protocol or via a remote shell such as RSH or SSH. In the latter case, the rsync client executable must be installed on both the local and the remote host. Speed wise I've not noticed much difference.

If lots of people going to connect your server, it is better to run it as daemon. For e.g. mirroring pubic ftp / http service.


----------



## gilinko (May 16, 2009)

I use rsync in daemon mode, and there is one thing that the daemon is better than a pure rsync path operation. In daemon mode there is no problem with spaces in file or path names, but in "ordinary" sync you have to escape any and all spaces.

http://www.samba.org/rsync/FAQ.html#9

Other then that I have not found any difference in performance when running the rsync daemon or a "pure" rsync command. The way I use it is to create a ssh tunnel from source to the backup rsync daemon port and then run the rsync over that connection. It's simple, secure and ridiculously easy to setup and does not expose the rsync daemon to the outside world.

Here is an extract from my script:

```
## Constants
BACKUP_SYSTEM="example.com"
LOCAL_RSYNC_PORT="1873"
REMOTE_RSYNC_PORT="873"

## Create the ssh tunnel
ssh -2 -N -T -f -L $LOCAL_RSYNC_PORT:localhost:$REMOTE_RSYNC_PORT $BACKUP_SYSTEM

## Test if the connection was successfull, otherwise exit
if [ $? -eq 255 ];
then
    exit
fi

## Verify the PID and store it for a future kill order 
SSH_TUNNEL_PID=`ps aux | grep 'ssh -2' | grep -v grep | awk '{print $2}'`

rsync -azq --delete /home/* rsync://localhost:$LOCAL_RSYNC_PORT/home

## Close the ssh tunnel as the it's not needed anymore
kill $SSH_TUNNEL_PID

exit 0
```


----------

