使用rsync过滤器包含/排除的文件 [英] Using Rsync filter to include/exclude files

查看:2264
本文介绍了使用rsync过滤器包含/排除的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想备份文件系统,排除的/ mnt ,但包括在的/ mnt 特定路径,它看起来像使用--filter建议在--include和--exclude,但是我似乎并没有能够得到它做我的招投标,例如:

I'm trying to backup a filesystem, exclude /mnt but include a particular path within /mnt, it looks like using --filter is recommended over --include and --exclude, however I don't seem to be able to get it to do my bidding , example:

rsync -aA -H --numeric-ids -v --progress --delete \
  --filter="merge /tmp/mergefilter.txt" /  /mnt/data/mybackup/

我/tmp/mergefilter.txt说:

My /tmp/mergefilter.txt says:

+ /mnt/data/i-want-to-rsyncthisdirectory/
- /dev
- /sys/
- /tmp/
- /run/
- /mnt/
- /proc/
- /media/
- /var/swap
- /lost+found/

所有开始的路径 - 被忽略了,但是我包括的/ mnt /数据/我想做到rsyncthisdirectory / 似乎从来没有得到的rsync 'D。为了和/或包含/排除的斜线不会出现改变有关我想包括在路径的行为。

All of the paths starting with "-" gets ignored, however my include for /mnt/data/i-want-to-rsyncthisdirectory/ seems to never get rsync'd. Order and/or including/excluding the trailing slash does not appear to change the behavior related to the path I want included.

编辑:注意,我的的要备份的/ etc / USR的/ var等,按指定为/源

Note that I do want to backup /etc /usr /var etc. as per the source specified as /

鸭preciate任何指导手册页是有点雷区......

Appreciate any guidance as the man page is a bit of a minefield...

推荐答案

对于我来说,这个命令做的工作:

For me, this command is doing the job:

rsync -aA -H --numeric-ids -v --progress --delete \
--filter="+ /mnt/data/i-want-to-rsyncthisdirectory/" \
--filter="- *" . /mnt/data/mybackup/

基本上,我用A +过滤器有问题的目录,并exlcude所有其他(如你在给定的例子一样)。

Basically, I used a + filter for the directory in question and exlcude all the others (as you do in your given example).

有没有必要明确地否定你不想要同步的目录。相反,你可以忽略所有除一个问题。

There is no need to explicitly negate all the directories you do not want to sync. Instead, you can ignore all except the one in question.

这篇关于使用rsync过滤器包含/排除的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆