O seguinte funciona para mim com rsync
versão 3.1.2:
$ ls -F
archive/ backup/ mk-archive.sh* mk-backup.sh* mk-cloud.sh* mk-source.sh* source/
$ cat /tmp/excludes
/archive/
/backup/
/mk-archive.sh
/mk-backup.sh
$ mkdir -p /tmp/target
$ rsync --relative --recursive --delete --delete-excluded --exclude-from=/tmp/excludes . /tmp/target/
$ ls -F /tmp/target
mk-cloud.sh* mk-source.sh* source/
O que está acontecendo aqui é conforme descrito na man page de rsync
, portanto, seus padrões devem ser ancorados em /
imediatamente no início da cópia (ou seja, em .
).
ANCHORING INCLUDE/EXCLUDE PATTERNS
As mentioned earlier, global include/exclude patterns are anchored at the "root of the transfer" [...].Because the matching is relative to the transfer-root, changing the trailing slash on a source path or changing your use of the
--relative
option affects the path you need to use in your matching (in addition to changing how much of the file tree is duplicated on the destination host). [...]Example:
cd /home; rsync -a --relative me/foo you/ /dest
+/- pattern:
/me/foo/bar
(starts at specified path)
+/- pattern:/you/bar/baz
(ditto)Target file:
/dest/me/foo/bar
Target file:/dest/you/bar/baz
Você pode ver as exclusões sendo processadas adicionando -vv
(ou --verbose --verbose
) ao comando rsync
.