backup: prevent exclude of backup targets

Track backup targets explicitly specified by the user and prevent
excluding them. This for example ensures that `restic backup
--exclude-if-present .git /home/user/data` backs up the `data` folder
even if there is a `.git` folder in `/home/user`.

Note that this does not suffice for commands like `restic backup --exclude data /home/user/data`
as the exclude pattern will still match every single file within `data`.
This commit is contained in:
Michael Eischer
2026-05-30 22:30:30 +02:00
parent c221cd06ad
commit 02cf8e5f23
6 changed files with 125 additions and 70 deletions
+14
View File
@@ -0,0 +1,14 @@
Change: Prevent excluding paths explicitly passed to `backup`
When `restic backup --exclude-if-present .git /home/user/data` was run and
`/home/user/.git` existed, restic excluded the `data` directory from the
snapshot. The same applied to `--exclude-caches` or `--one-file-system`. Similarly,
`restic backup --exclude-larger-than 1M large-file.bin` produced an empty
snapshot when the file was larger than one megabyte.
The `backup` command now tracks which files and directories were specified on
the command line and does not apply excludes to those paths. Content inside a
backed-up directory is still filtered by excludes as before.
https://github.com/restic/restic/issues/5767
https://github.com/restic/restic/pull/21797