Clarification needed on sync with filter

If you sync with a filter - does the filter only apply to the source, or source+destination?
In other words, will anything not inside the filter end up getting deleted on the destination?

Example:
DESTINATION: contains some files - aplha.txt + beta.txt, + charlie.txt
SOURCE: contains only a more recent version of alpha.txt

rclone sync SOURCE: DESTINATION: --include [a]*

What is the result?
(1) alpha gets updated, while beta and charlie get deleted?
or
(2) alpha gets updated, while beta and charlie are ignored?

I would assume (1), but it would nice to have confirmation on this.
Also - is there any way to get it to behave like (2) ?

Obviously this example is artificial and not truly representative. Telling me that I can just use move or copy for this spesific example would not be helpful. I would need it to work generally as sync normally does - except only considering the synced sub-sets on both sides.

Always easy just to try:

[felix@gemini ~]$ rclone sync -vv /home/felix/1 /home/felix/2 --include '[a]*'
2019/09/27 14:01:51 DEBUG : rclone: Version "v1.49.3" starting with parameters ["rclone" "sync" "-vv" "/home/felix/1" "/home/felix/2" "--include" "[a]*"]
2019/09/27 14:01:51 DEBUG : Using config file from "/opt/rclone/rclone.conf"
2019/09/27 14:01:51 DEBUG : beta: Excluded
2019/09/27 14:01:51 DEBUG : charlie: Excluded
2019/09/27 14:01:51 INFO  : Local file system at /home/felix/2: Waiting for checks to finish
2019/09/27 14:01:51 DEBUG : alpha: Sizes differ (src 263 vs dst 254)
2019/09/27 14:01:51 INFO  : Local file system at /home/felix/2: Waiting for transfers to finish
2019/09/27 14:01:51 DEBUG : alpha: MD5 = 013022cf346f5375a0d869fe43f1ef2c OK
2019/09/27 14:01:51 INFO  : alpha: Copied (replaced existing)
2019/09/27 14:01:51 INFO  : Waiting for deletions to finish
2019/09/27 14:01:51 INFO  :
Transferred:   	       263 / 263 Bytes, 100%, 691.251 kBytes/s, ETA 0s
Errors:                 0
Checks:                 1 / 1, 100%
Transferred:            1 / 1, 100%
Elapsed time:          0s

2019/09/27 14:01:51 DEBUG : 3 go routines active
2019/09/27 14:01:51 DEBUG : rclone: Version "v1.49.3" finishing with parameters ["rclone" "sync" "-vv" "/home/felix/1" "/home/felix/2" "--include" "[a]*"]
[felix@gemini ~]$ ls 1
alpha
[felix@gemini ~]$ ls 2
alpha  beta  charlie
[felix@gemini ~]$
1 Like

Huh, so it actually (2) then - and the filters apply on both sides. (correct me if I am wrong here).

Thanks Ani <3
It's mostly because I am a little paranoid about having ambiguous details in in potentially destructive commands that I wanted to ask for confirmation. Having your verification on it greatly reassures me :smiley:

This opens up a couple of new avenues for making my scripts more robust and effective. Very useful.

Yes the filters apply on both sides... However if you want to remove the filtered stuff on the destination then you use --delete-excluded

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.