我有一个像这样的 rsync 命令:
rsync -avz --exclude-from 'exclude-list.txt' -r /source/ destination
exclude-list.txt
看起来像这样:
.git
src
config.js
.gitlab-ci.yml
.gitignore
local-*
所有列出的文件和目录都与
exclude-list.txt
文件位于同一目录中。
因此,
.git
、src
和config.js
被跳过并且不被复制(就像我想要的那样),但其余项目仍然被复制。我的语法有什么问题吗? (local-*
应该是通配符,用于跳过以 local-
开头的所有文件)。
我在
rsync
上使用 Puppy Linux
遇到了这个问题,就我而言,有 2 件事让它运行良好
exclude.txt
中的文件路径始终相对于源目录。
e.g. /src/f_a/fileA , /src/fileB in exclude file will be
f_a/fileA
fileB
如果有空格或转义字符,那么至少在我的情况下它不尊重它们。因此,它只是以匹配的方式读取路径,看看它是否作为模式对齐,而不解释您的转义
e.g. /src/program files if written as
/src/program\ files or
/src/'program files'
后两者不会被匹配,并且文件夹不会被排除。只有第一个有效
exclude.txt
的路径可以指定为绝对路径或相对路径