Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

rsync filter merge help
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

rsync filter merge help

nfnnfn Veteran


I'm having some trouble using filters with rsync (not include/exclude).
I want to backup /etc and /srv starting from /, and exclude every match of tmp/ folders.

This is the command:

rsync -azhP --filter='merge /etc/backup/filter.txt' / user@remote:backup

This is my filter.txt:

# exclude filter
- tmp/**

# include filter
+ /etc/**
+ /srv/**

# exclude everything else
- *

The issue is the exclude pattern, I can't get it to work with '- ', '/' or '/**'.
I get:

[sender] hiding directory etc because of pattern *
[sender] hiding directory srv because of pattern *

What's the correct filter forma to backup only these folders using rsync filters?



  • matey0matey0 Member

    You need to include the parent directories /etc and /srv explicitly.

    It is also important to understand that the include/exclude rules are applied to every file and directory that the sender is recurs‐ ing into. Thus, if you want a particular deep file to be included, you have to make sure that none of the directories that must be traversed on the way down to that file are excluded or else the file will never be discovered to be included. As an example, if the directory "a/path" was given as a transfer argument and you want to ensure that the file "a/path/down/deep/wanted.txt" is a part of the transfer, then the sender must not exclude the directories "a/path", "a/path/down", or "a/path/down/deep" as it makes it way scanning through the file tree.

    Thanked by 1nfn
Sign In or Register to comment.