Rsync : Synchronize Files / Directories2026/01/07 |
|
Copy files or directories from one location to an another localtion by [rsync]. Basic usage of [rsync] is here. For Localhost ⇔ RemoteHost synchronizing, SSH is used for secure connection, so SSH Server is needed on RemoteHost.
On this example, Configure and Run [rsync] as a daemon. This example is based on the environment like follows. +----------------------+ | +----------------------+ | [dlp.srv.world] |10.0.0.30 | 10.0.0.51| [node01.srv.world] | | +----------+----------+ rsyncd | | /home/work/* | -------------> | /home/backup/* | +----------------------+ copy +----------------------+ |
| [1] | Configure on target host. |
|
node01:~ #
zypper -n install rsync
node01:~ #
vi /usr/etc/rsyncd.conf # add to last line # any name you like [backup] # target directory to copy path = /home/backup # hosts you allow to access hosts allow = 10.0.0.30 hosts deny = * list = true uid = root gid = root read only = false mkdir /home/backup node01:~ # ln -s /usr/etc/rsyncd.conf /etc/ node01:~ # systemctl enable --now rsyncd |
| [2] | On target host, if SELinux is enabled, change boolean setting. |
|
node01:~ # setsebool -P rsync_full_access on |
| [3] | On target host, if Firewalld is running, allow service. |
|
node01:~ # firewall-cmd --add-service=rsyncd success node01:~ # firewall-cmd --runtime-to-permanent success |
| [4] | Run synchronization from the source host to the target host. |
|
dlp:~ #
zypper -n install rsync
dlp:~ #
vi /usr/etc/rsyncd.exclude # specify files or directories you'd like to exclude to copy test test.txt
dlp:~ #
rsync -avz --delete --exclude-from=/usr/etc/rsyncd.exclude /home/work/ node01.srv.world::backup sending incremental file list ./ testfile.txt testdir/ sent 193,573 bytes received 46 bytes 387,238.00 bytes/sec total size is 868,252 speedup is 4.48 |
|
|