kmwoley / restic-windows-backup

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

Is there some way to prevent Windows going to standby while backup jobs are running? #63

Open TimH54 opened 2 years ago

TimH54 commented 2 years ago

I have had my machine going to standby while a backup job was running. It got interrupted. Is there some way for the scripts to prevent standby while the job is still running?

demlak commented 2 years ago

I am absolutly not familiar with windows-things.. i just start to dig into restic on windows.. but maybe this helps? https://winsourcecode.blogspot.com/2020/05/keepdisplayon-runs-program-preventing.html

kmwoley commented 1 year ago

Personally, this isn't behavior that I would want, but I can understand why you may want it. There was a feature request a while back to add the ability to run some pre- and post- backup actions to the script. If you found a way to tell Windows not to go to sleep in one script, and tell it that it's okay to go to sleep via another script, and then you could just call those two scripts from the backup, would that help you achieve your goal?

fetzerch commented 1 year ago

MS Powertoys contains a tool that could be used for this: https://learn.microsoft.com/en-us/windows/powertoys/awake#command-line-interface-cli.

The implementation pretty much does the same that has been linked above (Win32 SetThreadExecutionState API).