kmwoley / restic-windows-backup

Powershell scripts to run Restic backups on Windows
MIT License
330 stars 68 forks source link

Backup fails with "unable to open cache" #98

Closed ckewinjones closed 2 months ago

ckewinjones commented 3 months ago

My nightly restic backup job (using backup.ps1) is failing with 'Access is denied' on the cache directory. Here is the error reporting in backup.err.txt:

restic.exe : unable to open cache: chtimes \\?\C:\WINDOWS\system32\config\systemprofile\AppData\Local\restic\caf6a807bd
e3e9cadbd07c1f5657cf31376ab81142ed3eeafc7c1b29aba13b34: Access is denied.
At C:\restic\backup.ps1:82 char:14
+     $locks = & $ResticExe list locks --no-lock -q 3>&1 2>> $ErrorLog
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (unable to open ...cess is denied.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

and here is a clip from the XML specification for the Task Scheduler job, showing the Restic command it's issuing:

  <Actions Context="Author">
    <Exec>
      <Command>powershell.exe</Command>
      <Arguments>-ExecutionPolicy Bypass -NonInteractive -NoLogo -NoProfile -Command ".\backup.ps1; exit $LASTEXITCODE"</Arguments>
      <WorkingDirectory>C:\restic</WorkingDirectory>
    </Exec>
  </Actions>

The Task Scheduler job is running as user SYSTEM (SID S-1-5-18). The cache directory under %LOCALAPPDATA%) is owned by my personal user ID but SYSTEM is listed with Full Control permissions.

Any idea what the issue is here? I have been running this nightly backup job for about a month. It was working without error for a couple of weeks, but since July 4 it is failing nightly with this error. Possibly related is that there is a 'maintenance.log.txt' from July 3. The maintenance log shows that, in addition to culling snapshots etc, the maintenance log upgraded restic.exe to version 0.16.5.

Any tips to troubleshoot this would be appreciated.

20240704T0400021675.backup.err.txt 20240704T0400021675.backup.err.txt 20240704T0400021675.backup.log.txt

ckewinjones commented 3 months ago

I just noticed that the upgrade from restic 0.16.4 to 0.16.5 left version 0.16.4 in place as 'restic.exe.bak'.

I reverted to Restic 0.16.4 and launched my backup job. It ran to completion with no errors. It looks like this is an issue with restic itself rather than any problem with the backup.ps1 script.

ckewinjones commented 2 months ago

Per my last comment, not an issue with backup.ps1. Closing.