Problem using filtering

I am using rclone 1.51.0 on Windows 7 x64. I want to backup my e: drive but i want to include only specific directories and also exclude directories by name. I run this command rclone sync e: box-remote:backup --filter-from filter-file.txt. In the filter-file.txt i have this:
+ /dir1/**
+ /dir2/**
- cache/**
- *

Including specific directories works, but directories with the name cache are still uploaded.

Best to use the question template as we can't see the full command nor a debug log.

Normally, you'd want to put exclusions before the includes.

Can you share the full command with the debug log so we can see what it is doing?

Moving exclusions before includes fixed the issue. Thanks.

Debug log file, by the way, is empty. I used this command --log-file=log.txt.

Great that it is fixed.

An empty file means a command is incorrect but without the command being used, can't tell.

By the way, for encrypted remote can i use the command without specifying a remote path like this: rclone sync local_path remote-crypt: instead of rclone sync local_path remote-crypt:remote_path.

If it's an encrypted remote or a regular remote it really does not matter.

The filtering is all relative to the path you give it so it depends on the contents of your file and what you are trying to accomplish.

If you want to filter from a relative path, you can use that. If you want to filter from the root of your remote config, use that.

If you can describe what your use case is and what you are trying to accomplish, we can help figure out what the best approach is.

How to deal with directories that have spaces in their names? For example, directories like this + /one dir1/** won't get uploaded. I tried to put them in quotes like this + "/one dir1/**" but also didn't worked.

You'd need to share the full command and a debug log so we can see what's going on.

Just use a rclone ls command and add -vv on it and --dump filters

Like this:

felix@gemini:~$ rclone lsf GD: --exclude jelly* -vv --dump filters
--- start filters ---
--- File filter rules ---
- (^|/)jelly[^/]*$
--- Directory filter rules ---
--- end filters ---
2020/03/20 12:14:49 DEBUG : rclone: Version "v1.51.0" starting with parameters ["rclone" "lsf" "GD:" "--exclude" "jelly*" "-vv" "--dump" "filters"]
2020/03/20 12:14:49 DEBUG : Using config file from "/opt/rclone/rclone.conf"
2020/03/20 12:14:49 DEBUG : jellyfish-400-mbps-4k-uhd-hevc-10bit.mkv: Excluded
blah.zip
crypt/
dslrcli-linux-amd64.zip
test/
2020/03/20 12:14:49 DEBUG : 5 go routines active
2020/03/20 12:14:49 DEBUG : rclone: Version "v1.51.0" finishing with parameters ["rclone" "lsf" "GD:" "--exclude" "jelly*" "-vv" "--dump" "filters"]

I run this command: rclone lsf e: box-crypt: --filter-from filter-file.txt -vv --dump filters

This is the output:
# rclone lsf e: box-crypt: --filter-from filter-file.txt -vv --dump filters
--- start filters ---
--- File filter rules ---
- (^|/)cache/.$
- (^|/)Cache/.
$
- (^|/)Thumbnails/.$
+ ^one dir1/.
$
+ ^dir2/.$
- (^|/)[^/]
$
--- Directory filter rules ---
- (^|/)cache/.$
- (^|/)Cache/.
$
- (^|/)Thumbnails/.$
+ ^one dir1/.
/$
+ ^one dir1/$
+ ^one dir1/.$
+ ^dir2/.
/$
+ ^dir2/$
+ ^dir2/.$
- ^.
$
--- end filters ---
2020/03/20 18:37:27 DEBUG : rclone: Version "v1.51.0" starting with parameters ["rclone" "lsf" "e:" "box-crypt:" "--filter-from" "filter-file.txt" "-vv" "--dump" "filters"]

This is the content of the filter-file.txt:
- cache/**
- Cache/**
- Thumbnails/**
+ /one dir1/**
+ /dir2/**
- *

Can you run rclone ls as lsf only lists files. I didn't want to list out my entire GD as that's a lot of iles.

Use three backtics before and after code blocks

These `

3 before and 3 after

to make a code block and include you debug log.

This is the output:

# rclone ls box-crypt: --filter-from filter-file.txt -vv --dump filters
--- start filters ---
--- File filter rules ---
- (^|/)cache/.*$
- (^|/)Cache/.*$
- (^|/)Thumbnails/.*$
+ ^one dir1/.*$
+ ^dir2/.*$
- (^|/)[^/]*$
--- Directory filter rules ---
- (^|/)cache/.*$
- (^|/)Cache/.*$
- (^|/)Thumbnails/.*$
+ ^one dir1/.*/$
+ ^one dir1/$
+ ^one dir1/.*$
+ ^dir2/.*/$
+ ^dir2/$
+ ^dir2/.*$
- ^.*$
--- end filters ---
2020/03/20 19:24:02 DEBUG : rclone: Version "v1.51.0" starting with parameters ["rclone" "ls" "box-crypt:" "--filter-from" "filter-file.txt" "-vv" "--dump" "filters"]
2020/03/20 19:24:02 DEBUG : Using config file from "C:\\Users\\anon\\.config\\rclone\\rclone.conf"
        0 dir2/222
2020/03/20 19:24:03 DEBUG : 7 go routines active
2020/03/20 19:24:03 DEBUG : rclone: Version "v1.51.0" finishing with parameters ["rclone" "ls" "box-crypt:" "--filter-from" "filter-file.txt" "-vv" "--dump" "filters"]

Can you do the rclone ls without any filters and share the structure looks like? It doesn't seem your + are matching what you'd expect so it's dropped everything.

Do you mean this:

# rclone ls box-crypt:
        0 dir2/222

+ is matching dir2 directory, but doesn't match one dir1 directory because it has space in the name.

I can't see your screen. In the command you posted above, dir1 does not exist so it would not match since it's not there.

If you a rclone lsd box-crypt:, what's the output?

What are you trying to match or not match in the output?

Sorry, i did mistake with my test. I wanted to see how rclone will deal with directories that contain spaces in their names and changed the name of the directory in the filter-file.txt, but not the actual directory name. So stupid on my side. I apologize.
Everything is working fine now.

1 Like