I'm an idiot and don't understand filters. I'm attempting to use a minimal filter based on the docs, but from what I can tell it's not matching as I'd expect. I have a bunch of folders/files I'd like to sync but it keeps copying everything. I've pared my filter file down to two lines, an include for a specific file and then an exclude for everything else to try and start small and get that working but it seems like it's still trying to copy things in subdirectories.
Eventually I want to get to the point where I copy appdata/homeassistant/config/backups/* but not the rest of the home assistant directory. do I need to - each part of the path before getting there? Something like
A log from the command that you were trying to run with the -vv flag
2024/05/09 22:35:08 NOTICE: Automatically setting -vv as --dump is enabled
--- start filters ---
--- File filter rules ---
+ (^|/)rclone-filter\.txt$
- (^|/)[^/]*$
--- Directory filter rules ---
+ ^.*$
- ^.*$
--- end filters ---
2024/05/09 22:35:08 DEBUG : rclone: Version "v1.66.0" starting with parameters ["rclone" "sync" "/media/docker" "drive:Backup/Docker" "--filter-from" "/media/docker/slim.txt" "-i" "--dump" "filters"]
2024/05/09 22:35:08 DEBUG : Creating backend with remote "/media/docker"
2024/05/09 22:35:08 DEBUG : Using config file from "/home/chris/.config/rclone/rclone.conf"
2024/05/09 22:35:08 DEBUG : Creating backend with remote "drive:Backup/Docker"
2024/05/09 22:35:08 DEBUG : Google drive root 'Backup/Docker': 'root_folder_id = 0AAxeANHaf86DUk9PVA' - save this in the config to speed up startup
2024/05/09 22:35:09 DEBUG : docker-compose.yml: Excluded (Path Filter)
2024/05/09 22:35:09 DEBUG : docker-compose.yml: Excluded
2024/05/09 22:35:09 DEBUG : appdata: Directory modification time the same (differ by -155.921ยตs, within tolerance 1ms)
2024/05/09 22:35:09 DEBUG : compose: Directory modification time the same (differ by -407.567ยตs, within tolerance 1ms)
2024/05/09 22:35:09 DEBUG : secrets: Directory modification time the same (differ by -93.745ยตs, within tolerance 1ms)
2024/05/09 22:35:09 DEBUG : rclone-filter.txt: Size and modification time the same (differ by -391.187ยตs, within tolerance 1ms)
2024/05/09 22:35:09 DEBUG : rclone-filter.txt: Unchanged skipping
rclone: make directory "appdata/audiobookshelf"?
y) Yes, this is OK (default)
n) No, skip this
s) Skip all make directory operations with no more questions
!) Do all make directory operations with no more questions
q) Exit rclone now.
y/n/s/!/q> 2024/05/09 22:35:09 DEBUG : compose/snippet-box.yml: Excluded (Path Filter)
The part that confuses me is: rclone: make directory "appdata/audiobookshelf"
Why is it asking me to create that directory if the only include is rclone-filter.txt and everything else should be excluded? Is it because the appdata directory exists on the remote?
One downside to this though is that rclone can't be smart about not listing appdata since it won't know if it has a matching pattern. There is no way around this if you have other stuff to sync but if not, you're better off with
This is why it is not a good idea to mix --filter with --include and --exclude (and related). While the order that rclone considers them is documented, (a) it is error prone and (b) you can't mix and match + and - for better contro.
$ rclone sync /media/docker "drive:Backup/Docker" --filter-from /media/docker/slim.txt -i --dump filters
2024/05/10 08:00:19 NOTICE: Automatically setting -vv as --dump is enabled
--- start filters ---
--- File filter rules ---
+ (^|/)rclone-filter\.txt$
- (^|/)appdata$
- (^|/)appdata/.*$
- (^|/)appdata/[^/]*$
- (^|/)[^/]*$
- (^|/).*$
--- Directory filter rules ---
+ ^.*$
- (^|/)appdata/.*$
- ^.*$
- (^|/).*$
--- end filters ---
2024/05/10 08:00:19 DEBUG : rclone: Version "v1.66.0" starting with parameters ["rclone" "sync" "/media/docker" "drive:Backup/Docker" "--filter-from" "/media/docker/slim.txt" "-i" "--dump" "filters"]
2024/05/10 08:00:19 DEBUG : Creating backend with remote "/media/docker"
2024/05/10 08:00:19 DEBUG : Using config file from "/home/chris/.config/rclone/rclone.conf"
2024/05/10 08:00:19 DEBUG : Creating backend with remote "drive:Backup/Docker"
2024/05/10 08:00:19 DEBUG : Google drive root 'Backup/Docker': 'root_folder_id = 0AAxeANHaf86DUk9PVA' - save this in the config to speed up startup
2024/05/10 08:00:19 DEBUG : docker-compose.yml: Excluded (Path Filter)
2024/05/10 08:00:19 DEBUG : docker-compose.yml: Excluded
2024/05/10 08:00:19 DEBUG : appdata: Directory modification time the same (differ by -155.921ยตs, within tolerance 1ms)
2024/05/10 08:00:19 DEBUG : compose: Directory modification time the same (differ by -407.567ยตs, within tolerance 1ms)
2024/05/10 08:00:19 DEBUG : secrets: Directory modification time the same (differ by -93.745ยตs, within tolerance 1ms)
2024/05/10 08:00:19 DEBUG : rclone-filter.txt: Size and modification time the same (differ by -391.187ยตs, within tolerance 1ms)
2024/05/10 08:00:19 DEBUG : rclone-filter.txt: Unchanged skipping
rclone: make directory "appdata/audiobookshelf"?
y) Yes, this is OK (default)
n) No, skip this
s) Skip all make directory operations with no more questions
!) Do all make directory operations with no more questions
q) Exit rclone now.
y/n/s/!/q>
does it have something to do with the app directory existing on the remote already? the audiobookshelf directory isn't on the remote, however.
this seems to be working as I'd expect. but I'm still not sure why the other method didn't work. Does it create the directories regardless of whether it's syncing a file while it's on its way to search for any file named rclone-filter.txt? In my old example, shouldn't the appdata directory fail the first line, match on the second, and then not be created?
With my home assistant example, my filter looks like
Is it correct that all of those sibling directories are getting created? and, honestly, looking at your example. I'm not even sure why that worked . Shouldn't it have stopped at the first home assistant line and never gotten to the second?
here's the part I don't understand though, this doesn't work and copies all folders but not the files in the folders (I don't want the folders or the files). I was expecting that it would only create the directory tree where "rclone-filter.txt" exists
$ rclone sync --update --verbose --transfers 30 --checkers 8 --contimeout 60s --timeout 300s --retries 3 --low-level-retries 10 --filter-from /media/docker/slim.txt /media/docker "drive:Backup/Docker" --dump filters
2024/05/10 11:28:25 NOTICE: Automatically setting -vv as --dump is enabled
--- start filters ---
--- File filter rules ---
+ (^|/)rclone-filter\.txt$
+ (^|/)appdata/homeassistant/config/backups/.*$
- (^|/)appdata/homeassistant/[^/]*$
- (^|/).*$
--- Directory filter rules ---
+ ^.*$
+ (^|/)appdata/homeassistant/config/backups/.*/$
+ (^|/)appdata/homeassistant/config/backups/$
+ (^|/)appdata/homeassistant/config/$
+ (^|/)appdata/homeassistant/$
+ (^|/)appdata/$
+ (^|/)appdata/homeassistant/config/backups/.*$
- (^|/).*$
--- end filters ---
2024/05/10 11:28:25 DEBUG : rclone: Version "v1.66.0" starting with parameters ["rclone" "sync" "--update" "--verbose" "--transfers" "30" "--checkers" "8" "--contimeout" "60s" "--timeout" "300s" "--retries" "3" "--low-level-retries" "10" "--filter-from" "/media/docker/slim.txt" "/media/docker" "drive:Backup/Docker" "--dump" "filters"]
2024/05/10 11:28:25 DEBUG : Creating backend with remote "/media/docker"
2024/05/10 11:28:25 DEBUG : Using config file from "/home/chris/.config/rclone/rclone.conf"
2024/05/10 11:28:25 DEBUG : Creating backend with remote "drive:Backup/Docker"
2024/05/10 11:28:26 DEBUG : Google drive root 'Backup/Docker': 'root_folder_id = 0AAxeANHaf86DUk9PVA' - save this in the config to speed up startup
2024/05/10 11:28:26 DEBUG : appdata: Directory modification time the same (differ by -155.921ยตs, within tolerance 1ms)
2024/05/10 11:28:26 DEBUG : compose: Directory modification time the same (differ by -407.567ยตs, within tolerance 1ms)
2024/05/10 11:28:26 DEBUG : secrets: Directory modification time the same (differ by -93.745ยตs, within tolerance 1ms)
2024/05/10 11:28:26 DEBUG : rclone-filter.txt: Sizes identical
2024/05/10 11:28:26 DEBUG : rclone-filter.txt: Destination mod time is within 1ms of source and files identical, skipping
2024/05/10 11:28:26 DEBUG : appdata/jackett: Making directory with metadata
2024/05/10 11:28:27 INFO : appdata/jackett: Made directory with metadata (mtime=2024-05-07T21:52:01.438002383-04:00)
2024/05/10 11:28:27 DEBUG : appdata/jellyfin: Making directory with metadata
2024/05/10 11:28:28 INFO : appdata/jellyfin: Made directory with metadata (mtime=2024-04-28T20:22:07.295661416-04:00)
2024/05/10 11:28:28 DEBUG : appdata/komga: Making directory with metadata
2024/05/10 11:28:29 INFO : appdata/komga: Made directory with metadata (mtime=2024-05-10T10:41:55.75937599-04:00)
2024/05/10 11:28:29 DEBUG : appdata/mosquitto: Making directory with metadata
Why is ^.*$ getting added as a rule? to try and find rclone-filter.txt in any directory? If I change that to - rclone-filter.txt it doesn't create that rule.
I want the two tar files in appdata/homeassistant/config/backups and any file named rclone-filter.txt, one is currently at the root of the directory I'm copying and one is in appdata/bazarr. More might be added in the future. My expectation is that my remote will contain: ./rclone-filter.txt, appdata/bazarr/rclone-filter.txt, and the appdata/homeassistant/config/backups/*, but not any of the other folders in appdata.
Those first two are adding a + ^.*$ directory filter rule that is grabbing every single directory regardless of whether the files I want exist in them.
Ok - I think you have stumbled upon one of the side effects introduced by v1.66 new feature - directories metadata preservation.
It has been slowly worked on to rectify. For filters everything works again as it should in the latest beta.
If you do not want to use beta then roll back to 1.65.2 temporarily. Not sure if these changes will be included in v1.66.1 or only in v1.67
$ tree .
.
โโโ appdata
โ โโโ audiobookshelf
โ โโโ bazarr
โ โ โโโ rclone-filter.txt
โ โโโ cups
โ โ โโโ xxxx
โ โโโ esphome
โ โโโ homeassistant
โ โโโ config
โ โโโ automations.yaml
โ โโโ backups
โ โโโ 4c5effda.tar
โ โโโ f9e42559.tar
โโโ compose
โโโ docker-compose.yml
โโโ rclone-filter.txt
โโโ secrets
โโโ slim.txt
# rclone v1.66
$ rclone sync . drive:test --filter "+ rclone-filter.txt" --filter "- *" --dry-run
2024/05/10 18:50:01 NOTICE: appdata: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE: compose: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE: secrets: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE: rclone-filter.txt: Skipped copy as --dry-run is set (size 0)
2024/05/10 18:50:01 NOTICE: appdata/audiobookshelf: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE: appdata/bazarr: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE: appdata/cups: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE: appdata/esphome: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE: appdata/homeassistant: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE: appdata/homeassistant/config: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE: appdata/bazarr/rclone-filter.txt: Skipped copy as --dry-run is set (size 0)
2024/05/10 18:50:01 NOTICE: appdata/homeassistant/config/backups: Skipped make directory as --dry-run is set
2024/05/10 18:50:01 NOTICE:
Transferred: 0 B / 0 B, -, 0 B/s, ETA -
Transferred: 2 / 2, 100%
Elapsed time: 1.3s
# rclone v1.67 beta
$ rclone-beta sync . drive:test --filter "+ rclone-filter.txt" --filter "- *" --dry-run
2024/05/10 18:50:33 NOTICE: rclone-filter.txt: Skipped copy as --dry-run is set (size 0)
2024/05/10 18:50:33 NOTICE: appdata/bazarr/rclone-filter.txt: Skipped copy as --dry-run is set (size 0)
2024/05/10 18:50:33 NOTICE: appdata/bazarr: Skipped set directory modification time as --dry-run is set
2024/05/10 18:50:33 NOTICE: appdata: Skipped set directory modification time as --dry-run is set
2024/05/10 18:50:33 NOTICE:
Transferred: 0 B / 0 B, -, 0 B/s, ETA -
Transferred: 2 / 2, 100%
Elapsed time: 1.2s