kmwoley / restic-windows-backup

Powershell scripts to run Restic backups on Windows
MIT License
321 stars 67 forks source link

Unable to open rclone repo when running through Task Scheduler #67

Closed DoronLGN closed 1 year ago

DoronLGN commented 2 years ago

I can run backup.ps1 perfectly fine through command prompt or powershell, but when I try to run it through Task Scheduler I get the following error log:

restic.exe : Fatal: unable to open repo at rclone:Box:Desktop-Backup: cmd.Start: exec: "rclone": executable file not 
found in %PATH%
At C:\restic\backup.ps1:80 char:14
+     $locks = & $ResticExe list locks --no-lock -q 3>&1 2>> $ErrorLog
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Fatal: unable t...found in %PATH%:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

[[Backup]] Completed with errors
[[General]] Errors found. Log: C:\restic\logs\20220822T2237314423.err.txt

rclone is most definitely in a directory in my %PATH%, so I'm not sure what the cause of this problem might be. Some cursory Googling suggests this may be an issue with the syntax of exec, but that doesn't explain why it works fine when I run it manually.

rawtaz commented 2 years ago

Silly question but is it possible that your rclone binary is called rclone.exe and restic is trying to use just rclone?

DoronLGN commented 2 years ago

Silly question but is it possible that your rclone binary is called rclone.exe and restic is trying to use just rclone?

It's true that the binary is called rclone.exe, but I'm not sure why this problem would only show up when running it through Task Scheduler.

kmwoley commented 2 years ago

The scheduled task is running as a different user. Is it possible that user doesn’t have rclone in its path?

On Tue, Aug 23, 2022 at 4:34 PM DoronLGN @.***> wrote:

Silly question but is it possible that your rclone binary is called rclone.exe and restic is trying to use just rclone?

It's true that the binary is called rclone.exe, but I'm not sure why this problem would only show up when running it through Task Scheduler.

— Reply to this email directly, view it on GitHub https://github.com/kmwoley/restic-windows-backup/issues/67#issuecomment-1224992900, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOWG6CMS6QSY33FWA6DA43V2VNZ5ANCNFSM57J32F7Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

DoronLGN commented 2 years ago

That did turn out to be the case @kmwoley. However, even when I added rclone to the SYSTEM path variable, restic complained that the rclone conf file was missing. I'm considering switching the task to my user account in Task Scheduler, since that fixes the problem.

20220824T1521098144.err.txt .

kmwoley commented 2 years ago

That may be the easiest fix. If I recall, I made the task run as the SYSTEM account because it was simpler to make the install script that way. If I had used the user account, the install script would need to prompt for the user’s password.

There’s no reason not to change the task to your user account.

On Wed, Aug 24, 2022 at 1:52 PM DoronLGN @.***> wrote:

That did turn out to be the case @kmwoley https://github.com/kmwoley. However, even when I added rclone to the SYSTEM path variable, restic complained that the rclone conf file was missing. I'm considering switching the task to my user account in Task Scheduler, since that fixes the problem.

20220824T1521098144.err.txt https://github.com/kmwoley/restic-windows-backup/files/9419250/20220824T1521098144.err.txt .

— Reply to this email directly, view it on GitHub https://github.com/kmwoley/restic-windows-backup/issues/67#issuecomment-1226317979, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOWG6GC3WZWSBON7VX5O3DV22DQ3ANCNFSM57J32F7Q . You are receiving this because you were mentioned.Message ID: @.***>