rsync服务一排除打包

实例1:排除单个文件
1.查看客户端/data1目录的文件

[root@rsync-B ~]# ll /data1
total 0
-rw-r--r-- 1 500 500 0 Jul 22 22:47 a
-rw-r--r-- 1 500 500 0 Jul 22 22:47 b
-rw-r--r-- 1 500 500 0 Jul 22 22:47 c
-rw-r--r-- 1 500 500 0 Jul 22 22:47 d

2.排除文件a,推到服务端

[root@rsync-B ~]# rsync -avz --exclude=a /data1/ rsync_liang@10.0.0.129::liang --password-file=/etc/rsync.password 
sending incremental file list
./
b
c
d

sent 157 bytes  received 68 bytes  450.00 bytes/sec
total size is 0  speedup is 0.00

3.查看服务端文件

[root@rsync-A ~]# ll /liang1/
total 0
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 b
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 c
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 d

实例2:排除多个文件
1.清空服务端目录

[root@rsync-A liang1]# rm -rf *

2.客户端排除a,b文件,推到服务端

[root@rsync-B data1]# rsync -avz --exclude={a,b} /data1/ rsync_liang@10.0.0.129::liang \
--password-file=/etc/rsync.password
(方法二:rsync -avz --exclude={a..g} /data1/ rsync_liang@10.0.0.129::liang --password-file=/etc/rsync.password    )                 
sending incremental file list
./
c
d

sent 119 bytes  received 49 bytes  112.00 bytes/sec
total size is 0  speedup is 0.00

3.查看服务端目录

[root@rsync-A liang1]# ll 
total 0
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 c
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 d

实例3:不规律排除
1.客户端创建文件

[root@rsync-B data1]# touch {1..10}
[root@rsync-B data1]# ll
total 0
-rw-r--r-- 1 root root 0 Jul 23 01:00 1
-rw-r--r-- 1 root root 0 Jul 23 01:00 10
-rw-r--r-- 1 root root 0 Jul 23 01:00 2
-rw-r--r-- 1 root root 0 Jul 23 01:00 3
-rw-r--r-- 1 root root 0 Jul 23 01:00 4
-rw-r--r-- 1 root root 0 Jul 23 01:00 5
-rw-r--r-- 1 root root 0 Jul 23 01:00 6
-rw-r--r-- 1 root root 0 Jul 23 01:00 7
-rw-r--r-- 1 root root 0 Jul 23 01:00 8
-rw-r--r-- 1 root root 0 Jul 23 01:00 9
-rw-r--r-- 1  500  500 0 Jul 22 22:47 a
-rw-r--r-- 1  500  500 0 Jul 22 22:47 b
-rw-r--r-- 1  500  500 0 Jul 22 22:47 c
-rw-r--r-- 1  500  500 0 Jul 22 22:47 d

2.服务端清空环境

[root@rsync-A ~]# rm -rf /liang1/*

3.客户端执行动作

root@rsync-B ~]# seq 10 > paichu.log
排除与paichu.log文件内容一致的文件。
[root@rsync-B ~]# rsync -avz --exclude-from=/root/paichu.log /data1/ rsync_liang@10.0.0.129::liang --password-file=/etc/rsync.password   
sending incremental file list
data1/
data1/a
data1/b
data1/c
data1/d

sent 220 bytes  received 88 bytes  616.00 bytes/sec
total size is 0  speedup is 0.00

猜你喜欢

转载自blog.csdn.net/liang_operations/article/details/81182973