当前位置: > CentOS > CentOS服务器 > 文件同步 >

使用rsync排除多个文件

时间:2016-12-06 13:24来源:linux.it.net.cn 作者:IT

[root@atg-uat-storeserver-2-vm numen]# clear
[root@atg-uat-storeserver-2-vm numen]# cd /etc/xinetd.d
[root@atg-uat-storeserver-2-vm xinetd.d]# ls
chargen-dgram   daytime-dgram   discard-stream  eklogin       klogin       rmcp           tftp
chargen-stream  daytime-stream  echo-dgram      ekrb5-telnet  krb5-telnet  rsync          time-dgram
cvs             discard-dgram   echo-stream     gssftp        kshell       tcpmux-server  time-stream
[root@atg-uat-storeserver-2-vm xinetd.d]# vi rsync 
[root@atg-uat-storeserver-2-vm xinetd.d]# cp rsync rsync.bak20120609
[root@atg-uat-storeserver-2-vm xinetd.d]# vi 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
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}

[root@atg-uat-storeserver-2-vm xinetd.d]# cd /numen/
[root@atg-uat-storeserver-2-vm numen]# ls
awstats-7.0  awstats-7.0.tar.gz  logs  logsync.sh  rpc.rstatd-4.0.1  rpc.rstatd-4.0.1.tar.gz
[root@atg-uat-storeserver-2-vm numen]# mkdir logsync
[root@atg-uat-storeserver-2-vm numen]# cd logs
[root@atg-uat-storeserver-2-vm logs]# cd ../logsync
[root@atg-uat-storeserver-2-vm logsync]# 
[root@atg-uat-storeserver-2-vm logsync]# vi rsyncd.conf

uid = nobody
gid = nobody
use chroot = no
max connections = 50
pid file = /numen/logsync/rsyncd.pid
lock file = /numen/logsync/rsyncd.lock
log file = /numen/logsync/rsyncd.log

[apacheimg]
path = /numen/logs/
ignore errors
read only = no
list = yes
auth users = root
secrets file = /numen/logsync/rsyncd.secrets

[root@atg-uat-storeserver-2-vm logsync]# vi /numen/logsync/rsyncd.secrets
[root@atg-uat-storeserver-2-vm logsync]# 
[root@atg-uat-storeserver-2-vm logsync]# chmod 600 rsyncd.secrets 
[root@atg-uat-storeserver-2-vm logsync]# ps -ef|grep rsync |grep -v grep
[root@atg-uat-storeserver-2-vm logsync]# rsync --daemon --config=/numen/logsync/rsyncd.conf
[root@atg-uat-storeserver-2-vm logsync]# ps -ef|grep rsync |grep -v grep
root     12222     1  0 11:24 ?        00:00:00 rsync --daemon --config=/numen/logsync/rsyncd.conf
[root@atg-uat-storeserver-2-vm logsync]#

[root@fmw1 atglog]# vi /etc/rsyncd.secrets
[root@fmw1 atglog]# 
密码

 

rsync -av  root@10.58.13.22::apacheimg .  --password-file=/etc/rsyncd.secrets

 

 

 

 rsync -av --exclude 'access.log000*' --exclude '/bak' root@10.58.13.22::apacheimg .  --password-file=/etc/rsyncd.secrets
 
 rsync -av --exclude-from=atg-rules root@10.58.13.22::apacheimg .  --password-file=/etc/rsyncd.secrets
 rsync -av --delete --exclude-from=www-rsync-rules / remotehost:/dest/dir
 
 
 # 不传输 logs 目录
- /bak

# 不传输后缀为 .tmp 的文件
- access.log000*
- access.log0010*
- access.log0011*
- access.log0012*
- access.log0013*
- access.log0014*
- access.log0015*
- access.log0016*
- access.log0017*

# 传输 Apache 虚拟主机文档目录(/*/ 匹配域名)
#+ /srv/www/
#+ /srv/www/*/
#+ /srv/www/*/htdocs/
#+ /srv/www/*/htdocs/**

# 传输每个用户的 public_html 目录(/*/ 匹配用户名)
#+ /home/
#+ /home/*/
#+ /home/*/public_html/
#+ /home/*/public_html/**
# 禁止传输其他
#- *

[root@fmw1 atglog]# rsync -av --exclude-from=atg-rules root@10.58.13.22::apacheimg .  --password-file=/etc/rsyncd.secrets



(责任编辑:IT)
------分隔线----------------------------