I'm working on a deployment pipeline via rsync where I have to include/ exclude some special folders and files while there are also a lot of "unknown" files and folders on the destination which I'm not allowed to overwrite or delete.
Let's assume the following simplified structure while +/- means that it should or should not get included:
+ 1/
+ 1/11
+ 1/12
- 1/13
- 1/13/131
+ 1/13/132
+ 1/13/132/1321
+ 2/
+ 2/21
+ 3
- 4
- 5
- everything else
From my understanding, I designed the following rsync:
rsync -rltDvvO --delete --filter='merge .deploy' --dry-run ./ ../dest/
While the file .deploy has the following content:
# allowed folders
+ 1/***
+ 2/***
+ 3
# disallowed folders
- 1/13/***
# override disallowed subfolders to be allowed
+ 1/13/132/***
# disallow everything else
- *
The output is the following:
sending incremental file list
[sender] hiding file .deploy because of pattern *
[sender] showing file 3 because of pattern 3
[sender] showing directory 2 because of pattern 2/***
[sender] hiding file 5 because of pattern *
[sender] hiding file 4 because of pattern *
[sender] showing directory 1 because of pattern 1/***
[sender] showing directory 1/11 because of pattern 1/***
[sender] showing directory 1/13 because of pattern 1/***
[sender] showing directory 1/12 because of pattern 1/***
[sender] showing directory 1/13/131 because of pattern 1/***
[sender] showing directory 1/13/132 because of pattern 1/***
[sender] showing directory 1/13/132/132 because of pattern 1/***
[sender] showing directory 1/13/132/132/1321 because of pattern 1/***
[sender] showing directory 2/21 because of pattern 2/***
delta-transmission disabled for local transfer or --whole-file
3
1/
1/11/
1/12/
1/13/
1/13/131/
1/13/132/
1/13/132/132/
1/13/132/132/1321/
2/
2/21/
For some reason the priority of the rules seems to not be what I intended... is it even possible to filter folders like I need to?
I would like to have only one "rules file". That's why I tried to use filter instead of include-from and exclude-from.