Synchronizes files and directories by rsync

Synchronizes files and directories from one location to another location by rsync.

The example below is for automatical settings.

Copy files and directories in /data/proclog/ouxingning on a HostA[192.168.201.1] to in /data/ouxingning/backup on HostB[192.168.201.2].

1) Configure on Destination Host

yum -y install rsync xinetd
[root@ouxingning-5320-007 ~]# 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  # yes change to no
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}
[root@ouxingning-5320-007 ~]# /etc/rc.d/init.d/xinetd start
正在启动 xinetd:                                          [确定]
[root@ouxingning-5320-007 ~]# chkconfig xinetd on
[root@ouxingning-5320-007 ~]# mkdir -p /data/ouxingning/backup
[root@ouxingning-5320-007~]# vi /etc/rsyncd.conf
# indicates the source host, any name you like
[backuplog] # destination directory path = /data/ouxingning/backup # hosts you allow to copy (specify source host) hosts allow = 192.168.201.1 hosts deny = * list = true uid = root gid = root read only = false # specifie the name of a file that contains the username:password pairs secrets file = /etc/rsyncd.secrets
vi /etc/rsyncd.secrets

root:123456
chmod 600 /etc/rsyncd.secrets

 

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 /data/proclog/ouxingning/ 192.168.201.2::backuplog
# Add in cron if you'd like to run reguraly
[root@www ~]# crontab -e
# run at 2:00 AM in a day
00 02 * * * rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /data/proclog/ouxingning/ 192.168.201.2::backuplog

 

ps:

vi /etc/sysconf/selinx

setenforce 0  

#shell: setenforce 0 

 

 

转载于:https://www.cnblogs.com/ouxingning/archive/2012/11/02/synchronizes_files_by_rsync.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值