Excluding cargo build artefacts from borg backup

I'm looking for a reliable and concise way of excluding cargo's target directories from borg backups, using the borgpatterns.lst file.

The all seem to contain .rustc_info.json, and borg has an --exclude-if-present option, which looks like it might do the trick, but I don't see how to specify the exclude-if-present concept in the borgpatterns.lst syntax.

Edit: It turns out that not all of the cargo build directories contain .rustc_info.json.

You should look for a file called CACHEDIR.TAG. This indicates that the containing directory should be excluded from backups. Cargo creates this file in the root of the target dir and there are other programs which create this file too. See also Cache Directory Tagging Specification – Bryan Ford's Home Page.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.