How does restic invalidate the local cache when multiple machines are backing up to same repository?

Sequence of events :

  1. Machine 1 backups data
  2. Machine 2 backups data to same repo
  3. Machine 1 runs restic ls. Does it see the new files added by machine 2 ?

How does restic handle the cache in this scenario?

The complete data in a repository can be read by everyone with access to the repository (i.e., having a key for that repository). Thus, both machines could read each others data.

The cache contains a subset of the files in the repository. Each machine will simply download files that are missing in its cache once the contained data is required.

Will machine 1 see the new snapshots added by machine 2 ? Won’t the cache be old ?

cache is not used “offline” - machine 1 will list remote repository to check if cache is still valid and updates any missing/changed files.

1 Like

Two remarks:

  • IIRC, missing files in the cache are not created after the check. They are created in the cache when they are accessed. But there are many filetypes which are usually completely accessed like all snapshot files or all index files. However, superfluous files in the cache are removed after listing.
  • A very important property of the repository filenamess is that they are content-defined (the config file being the only exception). This means that files don’t change. If restic needs to change some contents of an existing file, it has to create a new file and remove the old one. This makes the caching pretty straightforward: There is no need for a change detection, only the need to detect new or removed files!