Running Rsync as a daemon on Ubuntu (HP Microserver build)



Rsync is a fast and extraordinarily versatile file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination. Rsync is widely used for backups and mirroring and as an improved copy command for everyday use.

Ubuntu out of the box provides an initiation script to run the rsync daemon at boot time, by default the daemon is disabled despite the existence of the initiation script. Here's how to enable the daemon to run at boot from the initialisation script.


Set RSYNC_ENABLE to true in the following files to enable rsyncd at boot:

sudo gedit /etc/init.d/rsync
sudo gedit /etc/default/rsync


Create the file /etc/rsyncd.conf configuration for rsync in daemon mode. The file should contain the following. In the file, user should be replaced with the name of user on the remote machine being logged into:

sudo gedit /etc/rsyncd.conf

Containing: 

max connections = 2
log file = /var/log/rsync.log
timeout = 300

[share]
comment = Public Share
path = /home/share
read only = no
list = yes
uid = nobody
gid = nogroup
auth users = user
secrets file = /etc/rsyncd.secrets
Create /etc/rsyncd.secrets for user's password. User should be the same as above, with password the one used to log into the remote machine as the indicated user.
sudo vi /etc/rsyncd.secrets

press 'a' then type your:

user:password

then press 'Esc', then type :wq! and press enter to exit vi.


This step sets the file permissions for rsyncd.secrets.

sudo chmod 600 /etc/rsyncd.secrets

Then run the following command to run the rsync daemon for the first time, alternatively reboot:

sudo /etc/init.d/rsync restart

Then run the following to check the status of the daemon:

sudo /etc/init.d/rsync status

The daemon must run with root privileges if you wish to use chroot, to bind to a port numbered under 1024 (as is the default 873), or to set file ownership. Otherwise, it must just have permission to read and write the appropriate data, log, and lock files. The daemon automatically runs with root privileges under the initialisation script.

1 comment:

Note: only a member of this blog may post a comment.