Skip to main content

Excluding directories from backup

Many applications generate large amounts of temporary or recoverable cache data (e.g. node_modules, thumbnail caches). This data usually does not need to be included in backups. The Cache Directory Tagging Specification standard exists to tag directories that contain such data. It defines a small tag file called CACHEDIR.TAG, which is stored at the root of a cache tree. These directories will then no longer be included in our backups.

For the automatically installed apps in mStudio, we have already placed the file in useful locations.

TL;DR

Create a file CACHEDIR.TAG in each cache directory with exactly the following first line:

Signature: 8a477f597d28d172789f06886806bc55

Requirements

There are only a few requirements for a valid CACHEDIR.TAG file:

  1. Filename: Must be exactly CACHEDIR.TAG (capitalisation important)
  2. Signature header: The first line must read exactly: Signature: 8a477f597d28d172789f06886806bc55
  3. Placement: A single CACHEDIR.TAG in the top-level cache directory is sufficient to mark the entire underlying directory tree as cache

When should you tag a cache directory?

Use CACHEDIR.TAG for directories whose content is regenerable - i.e. data that can be loaded from other sources or regenerated at any time. Typical examples:

  • Package/build caches (Composer, npm, Yarn)
  • Application caches (like TYPO3's var/cache directory)
  • Generated artefacts (thumbnails)
  • Backup directories managed by the application (e.g. Updraft)