Scientific Linux 6
Sponsored Link

rsync - Synchronizes files and directories2011/04/10

  Synchronizes files and directories from one location to another by rsync. Basic usage of rsync is here.

The example below is for automatical settings.
Ecxample ⇒ Copy files and directories in /var/www/html on a HostA[10.0.0.251] to in /home/backup on HostB[10.0.0.33].

[1] Configure on Destination Host
[root@lan ~]#
yum -y install rsync xinetd


[root@lan ~]#
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

}

[root@lan ~]#
/etc/rc.d/init.d/xinetd start

Starting xinetd:
[ OK ]

[root@lan ~]#
chkconfig xinetd on


[root@lan ~]#
mkdir /home/backup

[root@lan ~]#
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] Configure on Source Host
[root@www ~]#
yum -y install rsync


[root@www ~]#
vi /etc/rsync_exclude.lst


# specify files or directories you'd like to exclude to copy

test
test.txt

[3] It's OK. Execute rsync on Source Host like follows.
[root@www ~]#
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

[root@www ~]#

# 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
Matched Content