Help with include patterns in files-from

Hello everyone,

I am trying to backup a gocryptfs directory but only the gocryptfs.conf and gocryptfs.diriv files.

Hierarchy looks like this:

/a/b/gocryptfs.conf
/a/b/gocryptfs.diriv
/a/b/c/gocryptfs.diriv
/a/b/c/d/gocryptfs.diriv
/a/b/c/d/more/sub/dirs/gocryptfs.diriv

I was under the assumption that * matches everything except /, and ** matches everything including zero, one or more /.

If I backup with --files-from with the file content:

/a/b/gocryptfs.conf
/a/b/**/gocryptfs.diriv

I expect the entire tree matched, but it appears that only /a/b/c/gocryptfs.diriv match but not /a/b/c/d/gocryptfs.diriv or /a/b/c/d/more/sub/dirs/gocryptfs.diriv.

Any help?

If it’s easier to do with an --exclude-file, that’s okay too

I think this might be the problem. Looking through the forum it seems like this isn’t the case; apparently, golangs filepath package doesn’t support **.
The restic docs mention that files-from specifically uses filepath.Glob, and the docs for that seem to confirm it doesn’t support ** (there’s also an open issue, requesting the addition of support for **).

As an odd aside, the example exclude syntax in the restic docs specifically uses **. I’m not sure why that is, when I tested the behaviour, it behaved as two *'s, rather than a single **.

Anyway, if I understand what you’re after, essentially you want to back up only a specific filename in an arbitrary number of nested directories?

If so, I can’t think of a particularly “nice” way to do this in restic. The only suggestion that comes to mind would be to pass restic a list of the files generated using find via the --files-from-verbatim option, generated before each backup. The restic docs have an example showing this.

Sorry that’s probably not exactly what you were after, hopefully someone else has an idea for a cleaner solution.

1 Like