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
Cannot find docs for the exclude file syntax #1005
Comments
Hi, have you seen
in https://github.com/restic/restic/blob/master/doc/manual.rst? I think this should answer your questions. |
I went to the documentation at https://restic.readthedocs.io/en/latest/manual.html and searched for exclude, where it unfortunately doesn't include any common examples (or a reference to the other documentation at manual.rst) :/ |
I read the golang doc and I think the end-user (me!) isn't going to know what restic is comparing an exclude to internally - is it the full path (e.g. /home/me/blah) or a path from the repository root (/blah or blah), or relative to the cwd (me/blah when I am at /home)? |
Thanks for raising this issue, I think you have a valid point. The manual should explain the exclude filters without referencing godoc.org, and more examples are necessary. |
To answer a few of your questions already:
From your excludes file:
|
Thanks @fd0 So with "current directory", you don't mean the directory I was in when I launched the backup, but the directory that restic is currently in examining the files (apart from excludes that begin with a slash). Got it. The behaviour for files and directories is slightly unexpected, I would have expected --exclude foo/ to backup the directory but not the contents, whereas --exclude foo to backup neither. Not sure why, from rsync I guess. My examples missed an important one: spaces! I guess I need to escape those and shell metacharacters with a backslash. I ended up copying lots of these ones: https://gist.github.com/jult/e2eaedad6b9e29d95977fea0ddffae7d Are comments allowed in the excludes file? Edit: c796d84 looks like a hash is the comment character. |
Ah, I'm afraid that's still not completely correct. I'll describe how restic evaluates the exclude patterns. Let's suppose that restic is run by a user in his home directory (
Then restic will see the following command line arguments (after expansion by the shell):
Then, it starts traversing
I hope that this is a bit clearer now, I'll add a section to the manual describing the process. The key take-away point is that the patterns are evaluated against the full path of the files during backup. So if you want to match a single directory, use the complete path, otherwise it may match several times somewhere. Any further questions? :) |
I have further questions, and I very much appreciate the time you are taking to answer them. It's really one question about automagic anchoring of patterns. I think I can guess the answer (we rely on the absolute path being fairly unique and giving us the behaviour we want), but it's best to ask and be sure. Would the absolute pattern |
In both cases: No, the pattern won't match. |
Why is that? Edit: I'm pleased that it doesn't, but I don't see why that is :) |
The matching code there is modeled after what a shell would do: If you'd ask yourself, if the file In more formal terms: If the pattern starts with a You can imagine for yourself that the pattern and the file path are both split into their respective components:
When you have wildcards ( |
All these examples should be document in the manual I think. |
Gotcha. Thanks. |
Are negative excludes possible ala .gitignore? /etc/restic/excludes:
|
No, that is not implemented yet. |
Documenting include/exclude examples is tracked in #396, I'm closing this issue here. |
@fd0 i am trying exclude paths like below jobs//jobs//builds/**/archive to exclude archive dir from all directories would that work. And i have multiple paths like this which i need to exclude, if possible can you suggest me the best way to deal this kind as i cannot find any example for such kind in the documentation |
how can i exclude multiple files with with one flage? |
You have to specify the excludes as |
I can't seem to find any docs on how the exclude file syntax is parsed.
i.e. does it support wildcards? regex? how does it differentiate between files and directories? are path prefixes needed? where from (cwd/or root?)?
Some examples:
The text was updated successfully, but these errors were encountered: