Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the rsync filter -f 'hide,! */' do?

I want to sync only specific files with rsync. I found:

rsync --include='SpecificFiles*' -f 'hide,! */' ~/src ~/dst

The "include" is obvious, but what does the "-f ..." part do? Thank you!

like image 306
refle Avatar asked Mar 11 '23 15:03

refle


1 Answers

rsync --include='SpecificFiles*' -f 'hide,! */' ~/src ~/dst

First, the --include tells rsync to copy everything matching SpecificFiles*.

Second, the rule -f 'hide,! */' hides all non-directories. This means that no regular file is copied unless it was matched by the previous include rule.

In more detail, hide, starts a hide rule. Since */ matches all directories, its negation ! */ matches all non-directories. Thus, -f 'hide,! */' hides all non-directories.

As an aside, hide is similar to exclude unless a delete option is also specified. In that case, if a file that was hidden is already at the destination, it will be deleted just as if it did not exist at the source. By contrast, if a file that was excluded is already at the destination, the destination file will not be deleted.

like image 146
John1024 Avatar answered Mar 19 '23 18:03

John1024