Rsync : Synchronize Files / Directories2024/09/10 |
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. +----------------------+ | +----------------------+ | dlp.srv.world |10.0.0.30 | 10.0.0.51| node01.srv.world | | +----------+----------+ | | /root/work/* | -------------> | /home/backup/* | +----------------------+ copy +----------------------+ |
[1] | Configure on source host. |
root@dlp:~ #
pkg install -y rsync
root@dlp:~ #
vi /usr/local/etc/rsync/exclude.lst # specify files or directories you'd like to exclude to copy
test test.txt |
[2] | Configure on target host. |
root@node01:~ #
pkg install -y rsync
root@node01:~ #
vi /usr/local/etc/rsync/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 = wheel read only = false mkdir /home/backup root@node01:~ # service rsyncd enable rsyncd enabled in /etc/rc.conf root@node01:~ # service rsyncd start Starting rsyncd. |
[3] | That's OK, try to run [rsync] command on source Host. |
root@dlp:~ # rsync -avz --delete --exclude-from=/usr/local/etc/rsync/exclude.lst /home/work/ node01.srv.world::backup
sending incremental file list ./ testfile.txt testdir/ testdir/test2.txt sent 21,830 bytes received 65 bytes 43,790.00 bytes/sec total size is 72,604 speedup is 3.32 |
|