rsync:include和exclude参数

注意:include和exclude使用的目录,均为path定义的相对路径

环境:两台虚拟机128和130,在128上配置RsyncServer;130上做同步测试

rsync服务配置文件

vim /etc/rsyncd.conf

uid = nobody

gid = nobody

use chroot = no

max connections = 4

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

[nagios-53]

path = /opt

include = db1/

exclude = db1/1.log

read only = true

hosts allow = 192.168.128.130

hosts deny = 0.0.0.0/0

auth users = backup

secrets file = /etc/rsyncd/.rsync.pas

在128的/opt目录下有db1,db2,db3三个目录,里面分别有1.log、2.log、3.log文件

每次测试只修改配置rsync的配置文件,不需要重启rsync服务。

测试开始:

第一次:同步db1

include = db1/

exclude = db2/ db3/

同步命令

rsync -tvzrp --progress --password-file=/etc/.rsync [email protected]::nagios-53 /home

同步结果:

receiving file list ...

3 files to consider

./

db1/

db1/1.log

           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/3)

sent 140 bytes received 186 bytes 652.00 bytes/sec

total size is 0 speedup is 0.00

第二次:同步db1和db2

include = db1/ db2/

exclude = db3/

同步命令:

rsync -tvzrp --progress --password-file=/etc/.rsync [email protected]::nagios-53 /home

同步结果:

receiving file list ...

5 files to consider

./

db1/

db1/1.log

           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=2/5)

db2/

db2/2.log

           0 100%    0.00kB/s    0:00:00 (xfer#2, to-check=0/5)

sent 168 bytes received 262 bytes 860.00 bytes/sec

total size is 0 speedup is 0.00

第三次:只同步db1

include = db1/

exclude = *

同步命令:

rsync -tvzrp --progress --password-file=/etc/.rsync [email protected]::nagios-53 /home

同步结果:

receiving file list ...

2 files to consider

./

db1/

sent 118 bytes received 126 bytes 488.00 bytes/sec

total size is 0 speedup is 0.00

第四次:

include = db1/

exclude = db1/1.log

同步命令:

rsync -tvzrp --progress --password-file=/etc/.rsync [email protected]::nagios-53 /home

同步结果:

receiving file list ...

6 files to consider

./

db1/

db2/

db2/2.log

           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=2/6)

db3/

db3/3.log

           0 100%    0.00kB/s    0:00:00 (xfer#2, to-check=0/6)

sent 174 bytes received 280 bytes 908.00 bytes/sec

total size is 0 speedup is 0.00


第五次:

include = db1/

#exclude = db1/1.log

同步命令:

rsync -tvzrp --progress --password-file=/etc/.rsync [email protected]::nagios-53 /home

同步结果:

receiving file list ...

7 files to consider

./

db1/

db1/1.log

           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=4/7)

db2/

db2/2.log

           0 100%    0.00kB/s    0:00:00 (xfer#2, to-check=2/7)

db3/

db3/3.log

           0 100%    0.00kB/s    0:00:00 (xfer#3, to-check=0/7)


第六次:

#include = db1/

exclude = db1/1.log db2/ db3/

同步命令:

rsync -tvzrp --progress --password-file=/etc/.rsync [email protected]::nagios-53 /home

同步结果:

receiving file list ...

2 files to consider

db1/

sent 112 bytes received 120 bytes 464.00 bytes/sec

total size is 0 speedup is 0.00


你可能感兴趣的:(include,include,rsync)