Using Rsync filter to include/exclude files

前端 未结 3 1939
情歌与酒
情歌与酒 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:02

    In case someone else is battling with this as I am, I have managed to get the following to work. In my case I'm selectively sync repositories from another server.

    Place filters in a file:

    + epel/
    + epel/7/
    + epel/7/x86_64/
    + epel/7/x86_64/Packages**
    + epel/7/x86_64/repodata**
    - **
    

    And can then sync everything as intended with:

    cd /srv/repo
    rsync -rvzP -f 'merge /home/user/sync-filter.txt' ./ user@remote:/srv/repo/
    

    Initially, I had my filter file set up with epel/7/x86_64/Packages/**, which failed to work because of the trailing slash before the **. Removing the / made it all spring in to life as intended!

提交回复
热议问题