Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to exclude files through .gitignore #4227

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

civts
Copy link

@civts civts commented Mar 2, 2023

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

This PR is a first attempt to add the ability for restic to use .gitignore files to exclude entities from the backups.
Specifically, it defines a new flag, --exclude-gitignored, that can be used to enable the feature.

I tested this on linux and appears to work, but expect that I'll need to make more changes to ensure it functions cross-platforms and fits the style of the repo before merging. Looking forward for discussing this.

I used the gitignore parser provided by the go-git package.

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

This PR is related to issue #1514. (not sure if it can be considered as solved once it is merged since the conversation would also consider other VCSs as alternatives)

Known Issues

  • As of now, the gitignore parser of the go-git package has some corner cases in which it does not produce the correct result.
    See issues 694 and 154.
    Mentioning this in the docs may be enough to warn the users. Alternatively, we could consider another package for parsing the .gitignores

Checklist

  • I have read the contribution guidelines.
  • I have enabled maintainer edits.
  • I have added tests for all code changes.
  • 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 have run gofmt on the code in all commits.
  • All commit messages are formatted in the same style as the other commits in the repo.
  • I'm done! This pull request is ready for review.

@civts civts changed the title Add gitignore Add ability to exclude through .gitignore Mar 2, 2023
@civts civts changed the title Add ability to exclude through .gitignore Add ability to exclude files through .gitignore Mar 2, 2023
@stefnotch
Copy link

@MichaelEischer @fd0

I do humbly apologise for the ping. Is there any way you could find the time to take a look at this pull request? The author has expressed their intent to work on it, if this feature is deemed useful.

I fully understand how much work maintaining open source software can be, and wouldn't ask for anything more than a quick look and response. On that note, thank you very much for maintaining my favourite backup utility.

@MichaelEischer
Copy link
Member

MichaelEischer commented Sep 11, 2023

I fully understand how much work maintaining open source software can be, and wouldn't ask for anything more than a quick look and response.

I've already taken a quick glance at the PR and realized that I'll have to think quite a bit about it's design. In particular, I'm not convinced that it is a good idea to load all gitignores when starting the backup and the code also pulls in a pretty large number of new dependencies. As addressing these concerns requires quite a significant amount of changes, I'd like to think about it for some time before asking for such changes.

The isDir method is also prone to race conditions (compare to what the archiver sees). (e.g. rejectBySize directly works with the FileInfo from the archiver).

I'll be pretty short on time towards the end of the year, such that I probably won't have time this year to take a closer look.

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.

None yet

3 participants