CentOS 5
Sponsored Link

rsync - Sync Files
2015/01/19
 
Sync files or directories from one location to an another host by rsync.
Basic usage of rsync is here.
For example, Copy files or directories under the [/root/work] on dlp.srv.world to [/home/backup] on www.srv.world.
[1] Configure on source host.
[root@dlp ~]#
yum -y install rsync
[root@dlp ~]#
vi /etc/rsync_exclude.lst
# specify files or directories you'd like to exclude to copy

test
test.txt

[2] Configure on destination host.
[root@www ~]#
yum -y install rsync xinetd
[root@www ~]#
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@www ~]#
/etc/rc.d/init.d/xinetd start

Starting xinetd:
[ OK ]

[root@www ~]#
chkconfig xinetd on
[root@www ~]#
mkdir /home/backup

[root@www ~]#
vi /etc/rsyncd.conf
# any name you like

[backupdir]
# destination directory for 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
[3] It's OK. Execute rsync on Source Host like follows.
[root@dlp ~]#
rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /root/work/ 10.0.0.31::backupdir
# Add in cron if you'd like to run reguraly

[root@dlp ~]#
# for example, run at 2:00 AM in a day

00 02 * * * rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /root/work/ 10.0.0.31::backupdir
Matched Content
 
Tweet