What should we keep in mind when using CACHEDIR.TAG and .nobackup?
Are these synonyms, or should we expect that programs handle these differently?
What should we keep in mind when using CACHEDIR.TAG and .nobackup?
Are these synonyms, or should we expect that programs handle these differently?
The question you should be asking is "do these filenames have any special meaning at all for my specific backup configuration?"
Apparently BorgBackup has an option --exclude-caches which will automatically verify the signature of the CACHEDIR.TAG file wherever it's found and if it is correct, ignore the entire contents of the directory and all its sub-directories.
With some quick Googling on .nobackup, there appears to be no special support for it in BorgBackup, given that it's usually used like
borg recreate --exclude-if-present .nobackup /data/borg-backup
i.e. .nobackup is used as a parameter for the --exclude-if-present option, with no inherent special meaning for the filename.
The BorgBackup documentation describes these options like this:
--exclude-cachesexclude directories that contain a CACHEDIR.TAG file (http://www.bford.info/cachedir/spec.html)
--exclude-if-present NAMEexclude directories that are tagged by containing a filesystem object with the given NAME
Since both options are about excluding a directory if the specified file is in it, and --exclude-caches must by specification exclude that directory and all subdirectories, I must assume that --exclude-if-present NAME would have exactly the same effect, and that Borg documentation assumes that when a directory is excluded, it is understood without saying that all its subdirectories are excluded too.
So other than the content check on CACHEDIR.TAG, these options are effectively synonymous.
If you don't use the appropriate options, neither of these files have any special meaning.
If you use --exclude-caches, then validly-formed CACHEDIR.TAG files should cause the directory and its subdirectories be excluded, according to the linked specification.
If you use --exclude-if-present .nobackup, only the name of the file is checked: there is no specification for file contents, so false positives are theoretically more likely. But given the self-evident meaning of the filename, I don't think the risk is too great in practice.
You should run e.g. locate CACHEDIR.TAG and locate .nobackup as root on your own system(s) to evaluate how much benefit either of those options would provide to you. On my personal system, I see some programs (fontconfig, man and plocate) seem to have marked their caches with CACHEDIR.TAG files automatically, but none seem to have used .nobackup.
Sadly, the really big caches like Firefox's, Thunderbird's, Google Chrome's and Google Earth's don't seem to be automatically marked using either convention.
On the other hand, touch .nobackup is simple and needs no special knowledge. To create a CACHEDIR.TAG file, you'll need at least:
echo "Signature: 8a477f597d28d172789f06886806bc55" > CACHEDIR.TAG
So if you need to teach your users to maintain the marker files manually, it might be easier to teach them to create .nobackup files than valid CACHEDIR.TAGs.
On the other hand, if you can provide them (and/or yourself) a script (or similar "canned procedure") for marking a directory as to be excluded from backups, the difference in manual effort would be insignificant.