我有一个rsync脚本,它使用下面这行代码备份用户的主文件夹:
/usr/bin/caffeinate -i /usr/bin/rsync -rlptDn --human-readable --progress --ignore-existing --update $PATH/$NAME/ --exclude=".*" --exclude="Public" --exclude="Library" /Volumes/Backup/Users/$NAME\ -\ $DATE如何忽略~/Library/中除~/Library/Mail/之外的所有内容?我想包含这个rsync标志--include="/Library/Mail",但我不确定是否应该过于依赖rsync排除和包含,因为它可能变得不可靠,并且在不同版本的OS rsync中有所不同。
也许命令行正则表达式工具会更有用?示例:
ls -d1 ~/Library/*| grep -v '^mail' > $ALIST
exec <${ALIST}
read SRC
do
.
.
.
$RSYNC..etc...发布于 2015-10-15 07:58:23
rsync的--include和--exclude选项遵循所谓的“优先级”,因此您可以依赖一条严格的规则,这意味着在排除之前显式包含的内容将是发送的内容。
在您的示例中,在第一个--exclude之前添加--include ~/Library/Mail。
https://stackoverflow.com/questions/31528653
复制相似问题