Skip to content

backup: prevent exclude of backup targets#21797

Merged
MichaelEischer merged 3 commits into
restic:masterfrom
MichaelEischer:always-include-explicit-targets
May 31, 2026
Merged

backup: prevent exclude of backup targets#21797
MichaelEischer merged 3 commits into
restic:masterfrom
MichaelEischer:always-include-explicit-targets

Conversation

@MichaelEischer

Copy link
Copy Markdown
Member

What does this PR change? What problem does it solve?

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.

The code is mostly AI written with massive micromanagement to prevent overcomplicated implementations.

Was the change previously discussed in an issue or on the forum?

Fixes #5767

Checklist

  • I have added tests for all code changes, see writing tests
  • I have added documentation for relevant changes (in the manual).
  • There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I'm done! This pull request is ready for review.

@MichaelEischer MichaelEischer force-pushed the always-include-explicit-targets branch 2 times, most recently from d58168d to 4a9a766 Compare May 12, 2026 16:57
@MichaelEischer MichaelEischer force-pushed the always-include-explicit-targets branch from 4a9a766 to 42988d0 Compare May 30, 2026 20:15
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`.
@MichaelEischer MichaelEischer force-pushed the always-include-explicit-targets branch from 42988d0 to 795ad59 Compare May 30, 2026 20:30

@MichaelEischer MichaelEischer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread doc/040_backup.rst Outdated
@MichaelEischer MichaelEischer force-pushed the always-include-explicit-targets branch from 795ad59 to 7e8f9a9 Compare May 31, 2026 13:24
@MichaelEischer MichaelEischer merged commit 77a6bf3 into restic:master May 31, 2026
12 checks passed
@MichaelEischer MichaelEischer deleted the always-include-explicit-targets branch May 31, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Excluding with --exclude-if-present excludes whole source path

2 participants