Sincronizziamo da un server ad un altro una cartella
Esempio
⇒ copiamo da una cartella /var/www/html su un HostA[10.0.0.31] in /home/backup sull'HostB[10.0.0.33].
[1] Sull'host B
yum -y install rsync xinetd
vi /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no # change
flags= IPv6
socket_type = stream
wait= no
user= root
server= /usr/bin/rsync
server_args= --daemon
log_on_failure+= USERID
}
/etc/rc.d/init.d/xinetd start
Starting xinetd: [ OK ]
chkconfig xinetd on
mkdir /home/backup
vi /etc/rsyncd.conf
# any name you like
[site]
# destination directory
path = /home/backup
# Hosts you allow to copy (specify source Host)
hosts allow = 10.0.0.31
hosts deny = *
list = true
uid = root
gid = root
read only = false
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no # change
flags= IPv6
socket_type = stream
wait= no
user= root
server= /usr/bin/rsync
server_args= --daemon
log_on_failure+= USERID
}
/etc/rc.d/init.d/xinetd start
Starting xinetd: [ OK ]
chkconfig xinetd on
mkdir /home/backup
vi /etc/rsyncd.conf
# any name you like
[site]
# destination directory
path = /home/backup
# Hosts you allow to copy (specify source Host)
hosts allow = 10.0.0.31
hosts deny = *
list = true
uid = root
gid = root
read only = false
[2] Sull'Host A
yum -y install rsync
vi /etc/rsync_exclude.lst # specify files or directories you'd like to exclude to copy
test
test.txt
vi /etc/rsync_exclude.lst # specify files or directories you'd like to exclude to copy
test
test.txt
[3] Sull'Host di origine:
rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /var/www/html/ 10.0.0.33::site # Add in cron if you'd like to run reguraly
crontab -e # run at 2:00 AM in a day
00 02 * * * rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /var/www/html/ 10.0.0.33::site