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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章