garethgeorge/backrest

Make hooks work on windows installs

Closed this issue · 2 comments

I tried setting up a simple curl call to wake up my nas (backup target) before a backup plan is executed. When executing the plan backrest immediately cancels with the following error message:
cancelled: plan hook 0 on condition CONDITION_SNAPSHOT_START: cancel: exec: "sh": executable file not found in %PATH%

Backrest 1.2.1 is installed under Windows 10.
The hook/script in the backup's plan is a simple curl http://192.168.0.101/wol/nas

Curl is "native" to Powershell as in the curl cmd actually calls the Invoke-WebRequest cmdlet which on the other hand does not know arguments like -fsS and such (which are not needed in my case).

Looks like something along the lines of

   cmd := exec.Command("powershell", "-nologo", "-noprofile")

is a pretty standard set of options to fork powershell in golang. Can aim to update the defaults in https://github.com/garethgeorge/backrest/blob/main/internal/hook/hookcommand.go#L19-L33 to support this.

Supported under the umbrella of hook improvements in 1.3.0

https://github.com/garethgeorge/backrest/releases/tag/v1.3.0