Using Rsync filter to include/exclude files

前端 未结 3 1977
情歌与酒
情歌与酒 2021-02-08 13:54

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

3条回答
  •  轮回少年
    2021-02-08 14:10

    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/
    

    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.

提交回复
热议问题