How do exclude paths work when using relative include paths?

I’m working on a backup script that will be part of an application that will back up this application regardless of where it is installed.

Since environment variables are not expanded in the --files-from file, I’m using

cd $(dirname "$0")
restic --files-from=files

and then in files I have

../../data
../../.env

This works to back up the correct paths:

new       /.env, saved in 0.020s (209 B added)
new       /data/mysql/binlog.000035, saved in 0.001s (15.473 KiB added)

But now I want to exclude a specific path (../../data/mysql) using an exclude file (--exclude-file=excludes). Note that I do not want to exclude a path of this name anywhere else in the file tree, only at the backup root.

In the exclude file I have tried ../../data/mysql and also /data/mysql but neither will exclude the ../../data/mysql path.

This might not be the answer you want, but in case it helps: Priority ordering of exclude and include files - #5 by MichaelEischer

Excludes must use absolute paths. That is if ../../data/mysql resolves to /srv/data/mysql then you’d have to specify that.