9/15/2010

Configure Rsync to copy files

Following example based on a environment HostA is [192.168.1.18], HostB is [192.168.1.20].

1. Install xinetd first. It's necessary on HostA.

[root@vnlamp ~]#yum -y install xinetd

[root@vnlamp ~]#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
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID

}

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

[root@vnlamp ~]#chkconfig xinetd on

2. Config for HostA.

[root@vnlamp ~]#vi /etc/rsyncd.conf

[site] // name

path = /var/www/html // copied directory
hosts deny = *
list = true
uid = root
gid = root

3. Config for HostB.

[root@vnlamp-test ~]#vi /etc/rsync_exclude.lst

// Write directory or files you don't want to copy.

test
test.txt

4. Run Rsync.

[root@vnlamp-test ~]# rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst 192.168.1.18::site /home/backup

// add in cron if you'd like to run rsync.

No comments:

Post a Comment