rsync --include-from --exclude-from的理解:
1、同时添加--include-from --exclude-from时。后者是对前者的结果进行排除
如:“--include-from include.txt --include-from exclude.txt” #也就是说绝对不会超过--include-from声明的范围
2、--include-from 文件前面的符号是有效的有意义的
3、--exclude-from 文件前面不管是什么符号、有没有符号都是排除的意思

4、每一个目录、子目录、文件都会与这个过滤规则列表进行匹配,直到找到一个命中的(命中的规则说要过滤就过滤,要包含那就包含),

5、最重要的一个原则:只找第一个匹配的规则

以下是原文,我把关键词标出来方便阅读:

FILTER RULES

The filter rules allow for flexible selection of which files to transfer (include) and which files to skip (exclude). The rules either directly specify include/exclude patterns or they specify a way to acquire more include/exclude patterns (e.g. to read them from a file).

As the list of files/directories to transfer is built, rsync checks each name to be transferred against the list of include/exclude patterns in turn, and the first matching pattern is acted on: if it is an exclude pattern, then that file is skipped; if it is an include pattern then that filename is not skipped; if no matching pattern is found, then the filename is not skipped.

Rsync builds an ordered list of filter rules as specified on the command-line.

以下是一个实例后面添加对相关过滤规则的说明和理解

#############################################################################
### include.txt:
# CompanyAttachment Files
# 限制所有目录只包含2019开头的
- ETest/20191/ #如果非要排除 ETest/20191下的文件 这个排除规则应该放前面。每个路径只找第一个匹配的规则 (只找第一个、只找第一个、只找第一个 这很重要,理解了这个原则,才能理解所有的规则)
+ 2019*/ #这个只是包含了目录,目录下的文件不会同步
+ 2019*/** #这个只包含了目录下的文件,如果没有上面的这个也无效
+ ETest/ #这个只是包含了目录 但是子目录如果符合上面的其它条件也会被同步(如ETest目录下有2019开头的文件夹,也会同步)
- * #排除其它文件
- *.tmp #排除所有的.tmp文件。这是个错误的示例,这个不一定会排除所有目录的.tmp文件。因为有些路径会命中前面的规则就直接返回了。这个排除规则要么写到最前面,要么写到exclude.txt里去
#############################################################################
#############################################################################
# exclude.txt
*.tmp #exclude-from文件里不管前面加不加+、-号都是排除(测试+号、-号、不要符号结果是一样的,很奇怪,但测试结果是这样,不知道我是不是理解错误)
#* #exclude-from 是对include-from的结果进行排除,所以不能加这个。这个相当于禁用同步了。
#############################################################################

总结一下:

1、顺序很重要,重要的、命中范围小的写前面

2、最重要的还是理解它的过滤逻辑:每一个目录、子目录、文件都会与这个过滤规则列表进行匹配,直到找到一个命中的(命中的规则说要过滤就过滤,要包含那就包含),

rsync --include-from --exclude-from的理解的更多相关文章

  1. Webpack热加载和React(其中有关于include和exclude的路径问题)

    看了几个React配合webpack的教程,大部分都因为版本问题过时了.终于找到了一个不错的教程.记录下其中的知识点. 首先万分感谢这个教程的制作者.少走了许多弯路,正在学习webpack的小伙伴可以 ...

  2. ruby include和exclude区别

    很久没玩ruby了,今天看源码的时候,看到extend硬是缓不过神了,Google下extend和include的区别,做个记录 在class中include module, 那么module中的方法 ...

  3. maven <include>与<exclude>划定的范围存在冲突,则以<exclude>配置为准。

    maven 与划定的范围存在冲突,则以配置为准.

  4. rsync --exclude 参数

    /usr/bin/rsync -vr --exclude=".svn" --exclude="temp" --delete /alidata/www/pro/e ...

  5. pandas.DataFrame.describe 官方文档翻译percentile_width,percentiles,include, exclude

     使用格式:DataFrame.describe(percentile_width=None, percentiles=None, include=None, exclude=None)  作用:生成 ...

  6. zzw原创_expdp及impdp中的exclude及include参数的那点事

    zzw原创:转载请注明出处 在oracle的expdp 及imdpd命令中,exclude及include参数还是有一些要注意的地方,特别是涉及选择性条件时. 一.通用 1.exclude及inclu ...

  7. rsync详解之exclude排除文件

    rsync详解之exclude排除文件 问题:如何避开同步指定的文件夹?  --excludersync  --exclude files and folders http://articles.sl ...

  8. rsync详解之exclude排除文件(转)

    rsync详解之exclude排除文件 问题:如何避开同步指定的文件夹?  --excludersync  --exclude files and folders http://articles.sl ...

  9. expdp,impdp,include,exclude

    The examples below are based on:- the demo schema SCOTT that is created with script: $ORACLE_HOME/rd ...

  10. rsync详解之exclude排除文件【转】

    rsync详解之exclude排除文件 问题:如何避开同步指定的文件夹?  --exclude rsync  --exclude files and folders http://articles.s ...

随机推荐

  1. Win7下无法启动sql server fulltext search (mssqlserver)的问题

    在Win7下安装了SQL Server 2005, 但启动“SQL Server FullText Search (MSSQLSERVER)”服务时启动不成功,系统日志显示“SQL Server Fu ...

  2. mongdb window 服务安装批处理

    安装mongodb 3.x 安装完毕后 将以下代码保存为批处理 然后用管理员权限执行就可以成功安装服务了 cd C:\Program Files\MongoDB\Server\3.0\binmongo ...

  3. linux03

    linux day31.正则表达式 \* ------重复0无数次 \+ ------重复1 无数次 ^ -------开头 $ -------结尾 | ------或 & ----- 与 ( ...

  4. 模拟ssh、黏包、hashlib模块

    一.模拟ssh 1.subprocess模块 ipconfig -all dir subprocess模块是python从2.4版本开始引入的模块.主要用来取代 一些旧的模块方法,如os.system ...

  5. Spring Boot中使用@Async实现异步调用

    在Spring Boot中,我们只需要通过使用@Async注解就能简单的将原来的同步函数变为异步函数,为了让@Async注解能够生效,还需要在Spring Boot的主程序中配置@EnableAsyn ...

  6. ubuntu14中把openssh升级到7.5

    经验证可用 下载相关tar.gz包,没有下载到的,可以在这里下载.http://download.csdn.net/download/songanshu/10023663 apt install -y ...

  7. centos7上mysql5.6版本主从复制

    做主从复制实验: 第一步:主服务器上操作 1.修改主服务器master: [root@localhost ~]# vim /etc/my.cnf server_id = 1  //[必须]服务器唯一I ...

  8. Eleasticsearch启动失败问题解决

    问题: [root@dnode1 bin]# ./elasticsearch -d [root@dnode1 bin]# Exception in thread "main" ja ...

  9. 【从0到1学Web前端】CSS定位问题一(盒模型,浮动,BFC) 分类: HTML+CSS 2015-05-27 22:24 813人阅读 评论(1) 收藏

    引子: 在谈到css定位问题的时候先来看一个小问题: 已知宽度(假如:100px)div框,水平居中,左右两百年的分别使用div框填充.且左右div自适应. 效果如下图: 这个问题的难点主要是浏览器宽 ...

  10. 微信 JS-SDK 签名验证

    doc: http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html demo:http://demo.open.weix ...