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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值