Setting Rsync Daemon
Last updated
Last updated
We already leared about the powerful rsync for transferring files. Now, we will implement rsync on a Network-attached Storage (NAS). Assumed we have two server2 and one NAS. All these devices is connected with each other via local area network (LAN).
The port mapping is as following:
server1: 192.168.0.1
server2: 192.168.0.2
myNAS: 192.168.0.3
And we have two different to backup files from servers seperately. (though volumes can be the same partition technically)
server1 /home/ -----> sync to NAS /volumes/server1
server2 /home/important -----> sync to NAS /volumes/server2/important
NAS is just an self-contained, file-level storage server connected to a network. It is actually a tiny computer that powered with some abilities to store and aceess files more elegantly. In this manual, we would use the Synology's NAS for example.
Before we start, you must setup all the volume, RAID, and other stuff in your NAS. Synology's product have a decent web-base operating system called DiskStation Manager (DSM). You can read their documents to get started.
First, login DSM. Open the Control Panel, then select File Services.
Check the Enable rsync service field.
Then, add your super user as a rsync account to enable rsync daemon access.
rsyncd.conf
After previous steps, NAS start rsyncd daemon automatically for you. The rest you have to do is specify different setting between servers.
While we enable rsync in NAS DSM, we also enable ssh via TCP port 22 by default. However, the ssh service on NAS system is only for local network usage. We would keep it in LAN. No port forwardgin to WAN.
Thus, if we want to ssh-login NAS system, we need to use either a device in the same LAN.
Next, open the rsync configure file /etc/rsyncd.conf
.
Here are a example rsyncd.conf
file:
After finishing configure rsyncd.conf
, you should create secrets file at the path you specified. Assumed you set the path at /etc/rsyncd.secrets
. Open it.
Then follow the username:password
pattern for the authentication. For security issue, try to avoid using the same password as the server account.
And the important part. You should use chmod
to change access for the secrets file, otherwise rsyncd wont be able to work.
At last, check there isn't any process running. Then reboot you NAS (Maybe there is another way to restart rsync daemon, but I have no idea with Synology DSM.)