rsync files/folders 来自输入文件中的列表并从排除文件中排除

rsync files/folders from a list in an input file and exlude from an exclude file

我有两个包含文件夹列表的文件。我想将具有相对路径的文件夹同步到不包括排除文件中的目标的目标。

$ cat include.txt
/home/user
/etc
/data/app
/boot

$ cat exclude.txt
/data/app/temp
/etc/aide

我试过使用 --include-from--files-from 但似乎无法理解。

这似乎同步了文件夹,但没有同步文件:

rsync -av --files-from=include.txt / /destination

最终我想同步到 /destination 并且文件夹结构如下所示:

/destination/home/user
/destination/home/user/...
/destination/etc
/destination/etc/...
/destination/data/app
/destination/data/app/...
/destination/boot
/destination/boot/...

只需添加 -r--exclude-from 选项,您就可以开始了:

rsync -av -r --files-from=./include.txt --exclude-from=./exclude.txt / /destination/