The cache directory is explicitly set by the backup script to $global:CACHEDIR = “C:\Users\X\Documents\utilities\restic\cache_dir${RESTIC_SOURCE_DRIVE}”
$env:CACHEDIR = $CACHEDIR
Users\X\Documents\utilities\restic> .${RESTICEXE} version
restic 0.18.1 compiled with go1.25.1 on windows/amd64
PS C:\Users\X\Documents\utilities\restic> Write-Host “cacheeddir ${CACHEDIR}”
cacheeddir C:\Users\X\Documents\utilities\restic\cache_dir\C
PS C:\Users\X\Documents\utilities\restic> .${RESTICEXE} cache --cleanup
no old cache dirs found
When the “cache --cleanup” is run restic respond with “no old cache dir found”.
but when I manually look at the directory there are a bunch of old cache directories.
Directory: C:\Users\X\Documents\utilities\restic\cache_dir\C
Mode LastWriteTime Length Name
d---- Saturday:2022-12-24 8:45 38d972fad83859820d7906e9522674daa0e1e40807df73ef09c8c1a37a379191
AM
d---- Monday:2025-10-06 2:25 PM 5e44757d7316081b95ca744bea1da5638bea97101bc6aa9a5346d4a947dc6476
d---- Tuesday:2024-12-17 1:31 cf0c7fe40a1ff443c131d387e06edaf005fe35f6cd9a08c2f3597b3339ba995e
PM
d---- Sunday:2021-12-26 2:28 PM df3c24e1793821151b6046556d724861b21c0ca13296d376356852cdbd4b5d46
d---- Tuesday:2021-11-23 2:08 e5137ba775c0d4ecdfefb30a65f2cd27a0469814c71568d689934802475eda7c
PM
d---- Wednesday:2023-12-27 f12261a2baee5831712b210006ad6b11661a51cefaa81cf10e34c87d0c39a393
10:43 AM
As you can see most of the directories are not even from the year 2025 so why didn’t restic delete them? Does the cleanup command only look for the cache related to the current repository? If I had done a test backup with a different, i.e. “test”, repository would the cache be deleted or would it always remain until I found it manually, and deleted it manually?
Also there is a file in the cache directory called CACHEDIR.TAG what is it for, what does it do?
Since I create a completely new repository each calendar year, does that mean I can delete any cache dir which has not been updated in 2025 without any problems? The actual repository is on a external local disk. (Can all cache be deleted as long as the repository exists and restic will recreate the cache as necessary?) The cache dir is on a ssd so I would like to keep it clean.
Thank you.