分页: 1 / 1

rsync exclude 困惑

发表于 : 2023-04-07 8:41
百草谷居士
在使用 rsync 同步文件时,使用 --exclude 或者 --exclude-from=filelist 时,有些困惑
1、如果想排除一级文件夹 xyz ,但是不排除名为 xyz 的子文件夹时,应该如何指定?
2、Windows回收站文件夹 $RECYCLE.BIN ,如何指定?我直接把这个文件夹名写到 excludefilelist 中后,反而会自动建立这个文件夹,搞得这个文件夹到处都是。

Re: rsync exclude 困惑

发表于 : 2023-04-07 10:07
astolia
有空去花时间读一下manpage中的描述,就不用当伸手党了

代码: 全选

$ find
.
./c
./c/b
./b
$ rsync -av --exclude='/b' . /tmp/x
sending incremental file list
created directory /tmp/x
./
c/
c/b/

sent 117 bytes  received 56 bytes  346.00 bytes/sec
total size is 0  speedup is 0.00

$ find
.
./a.txt
./$RECYCLE.BIN
$ cat a.txt
$RECYCLE.BIN
$ rsync -av --exclude-from=a.txt . /tmp/y
sending incremental file list
created directory /tmp/y
./
a.txt

sent 146 bytes  received 67 bytes  426.00 bytes/sec
total size is 13  speedup is 0.06
$ rsync -av --exclude='$RECYCLE.BIN' . /tmp/z
sending incremental file list
created directory /tmp/z
./
a.txt

sent 146 bytes  received 67 bytes  426.00 bytes/sec
total size is 13  speedup is 0.06

Re: rsync exclude 困惑

发表于 : 2023-04-10 13:09
百草谷居士
我测试测试