Ubuntu 26.04

Rsync : Synchronize Files / Directories2026/06/19

 

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.
Rsync daemon [rsyncd] uses [873/TCP], so SSH service is not needed on this case.

This example is based on the environment like follows.

+----------------------+          |          +----------------------+
|     dlp.srv.world    |10.0.0.30 | 10.0.0.51|   node01.srv.world   |
|                      +----------+----------+                      |
|     /root/work/*     |   ------------->    |     /home/backup/*   |
+----------------------+        copy         +----------------------+

[1] Configure on target host.
root@node01:~#
apt -y install rsync
root@node01:~#
vi /etc/rsyncd.conf
# create new
# 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

root@node01:~#
mkdir /home/backup

root@node01:~#
systemctl start rsync
# if UFW is enabled, allow service port

root@node01:~#
ufw allow 873/tcp
[2] Configure on source host and try to run [rsync] command on source Host.
root@dlp:~#
apt -y install rsync
root@dlp:~#
vi /etc/rsync_exclude.lst
# specify files or directories you'd like to exclude to copy

test
test.txt

root@dlp:~#
rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /home/work/ node01.srv.world::backup
sending incremental file list
deleting testfile2.txt
./
test1.txt
testfile.txt
usermin-current.deb
webmin-current.deb
testdir/

sent 38,009,081 bytes  received 241 bytes  76,018,644.00 bytes/sec
total size is 38,013,059  speedup is 1.00
Matched Content