rsync



include/exclude



rsync 支持使用 include/exclude 来过滤要同步的文件,使用这两个参数的时候,需要注意下面的这个问题
Note that, when using the –recursive (-r) option (which is implied by -a), every subcomponent of every path  is  vis‐
        ited  from the top down, so include/exclude patterns get applied recursively to each subcomponent’s full name (e.g. to
        include "/foo/bar/baz" the subcomponents "/foo" and "/foo/bar" must not be excluded).  The exclude  patterns  actually
        short-circuit  the  directory  traversal stage when rsync finds the files to send.  If a pattern excludes a particular
        parent directory, it can render a deeper include pattern ineffectual  because  rsync  did  not  descend  through  that
        excluded section of the hierarchy.  This is particularly important when using a trailing ’*’ rule.  For instance, this
        won’t work: 

/some/path/this-file-will-not-be-found
/file-is-included 
*
rsync 使用 -r 来遍历子目录的时候,如果还想用 exclude include 来过滤文件,那么要注意 一个目录如果满足了 exclude,而且还没有对应的 include,那这个目录下面的子目录也会被 exclude,就算你对这个子目录写了 include 。 虽然能解决问题,可实在很费劲,直到无意中发现了 files-from 参数。

files-from

files-from 是通过指定一个本地/远程的文件来定义需要同步的文件。这个文件生成方法可就多了,你可以用 find/sed/awk/xxxxx 等搭配来得到你这个文件,一行命令不够还可以多行,是不是爽多了?
如果是远程文件,那就 –files-from=:/path/to/files。

写在后面

顺便测试一下 org2blog,这帖子是用 org2blog 写的,给作者提了个建议,加上 permlink 的支持,没几天居然给加上了,刚好测试一下,呵呵。