Skip to content

Anchored excludes #604

@riastradh

Description

@riastradh

Suppose I have the following directory tree:

  • ./
    • foo
    • bar
    • a/
      • foo
      • bar

Suppose I want to exclude ./foo, but include everything else -- including ./a/foo.

  • If I use tarsnap -c ... --exclude ./foo ., that excludes both of them.
  • --include isn't open-ended, so I can't use it without enumerating everything else like ./bar too.
  • If I use tarsnap -c ... --exclude /foo ., that doesn't exclude anything.

This comment suggests the possibility of anchored matches for --exclude was considered incompletely and was meant to be re-considered:

tarsnap/tar/matching.c

Lines 70 to 73 in dfcc22d

* The matching logic here needs to be re-thought. I started out to
* try to mimic gtar's matching logic, but it's not entirely
* consistent. In particular 'tar -t' and 'tar -x' interpret patterns
* on the command line as anchored, but --exclude doesn't.

I can use some elaborate system of find(1) patterns piped to tarsnap to achieve the same result, but it would be nice if I could simply specify anchored path patterns in the exclusion file. I think the syntax of --exclude /foo is not currently useful so it could probably be used for this purpose, like in .gitignore files.

I realized this today when I discovered that the exclusion was broader than I intended, resulting in some files not being backed up when I thought they would be for years. (Fortunately, in my case, the files are not important.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions