Backing up specific files with tags on macOS

Hello.

I’ve checked the docs but haven’t come up with an option to achieve this.

I have a directory that I want to backup but I only want the files that are tagged to be backed up. For instance, here is a sample structure:

  • Root
    • file [tagged]
    • file 2 [tagged]
    • file 3
    • file 4
    • file 5
    • folder 1
      • file 1
      • file 2 [tagged]
      • file 3

For the above case, only the files with the [tagged] would be backed up by restic.

I’m on macOS Catalina. For the tagging operation, I’m making use of the Finder’s own tagging feature. I know this is pretty platform specific but is there a way I can achieve this with restic without me chaging the structure of my directory? Or should I retreat to some other solution? If so, could you please elaborate.

Thanks.

I think what you can do is; listing the filenames you want to backup in a file and using --files-from option to give this file. Restic will read the files it needs to backup from this given file. (Not sure how to extract tagged file paths to a file though, I’m alien to macos.)

I’m guessing you can use mdfind to find files with the given tag(s), see e.g. https://apple.stackexchange.com/questions/93979/are-the-osx-mavericks-tags-visible-from-the-command-line and man mdfind.

And then pipe/format the result into a file that you then give to --files-from as already suggested by @gurkan. If paths change a lot you might need to use the --parent flag to backup.

EDIT: There’s also https://github.com/jdberry/tag which might be easier for you to find the relevant files.