Automating windows usage

I’m looking at setting up restic on a windows laptop.

Things I foresee needing to implement:

  1. Setting environment variables
  2. Scheduling restic to backup / self-update / check
  3. Running as low priority
  4. Cancelling backup on connection to metered network connection (allow for retry on normal reconnection)
  5. Scheduling restic to self-update
  6. Using a VSS snapshot
  7. Reporting backup failures
  8. Writing a script to do all of the above (surely this has all been done before?)

How are the above done in a Windows environment?

[Note: I don’t want to use relica which would waaaay more than double my yearly costs]

I use blat for emailing successes, or in some cases just errors. You’ll want to ensure you schedule repo checks as well as forget+prune. If using Windows 10 and the task scheduler, I’ve come across the following two (batshit crazy) regressions since Win7:

  • If restic.exe is in a path with a space then the Command Line field has to be unquoted, and then you have to accept the error. This will then munge the path and arguments items across the Command Line and Arguments fields but it will still work. Trust, but verify, however! If you don’t do this, Windows will double-quote the lot and it will fail to execute.
  • If you edit a task after creating it, you must re-set the user account the task uses, otherwise the task will fail. So each time you edit a task, go back to the General tab, click “Change User or Group”, enter the user name, hit OK and enter the password again.

That’s pretty mad indeed.

I’m having scheduler run a batch script, so as to set variables and also work around the Arguments field issue you mention.

I read somewhere else (tab is closed now) that you’ve written some scripts. You seem to have above average clue, so I’d expect they would be a great starting point.

Would you be willing to share them?

They vary from case to case and restic is pretty well-behaved so I don’t envisage you having problems making your own to fit your requirements, but do feel free to ask if you have any specific problems or questions.

@ProactiveServices in terms of automation, you may be interested in:

Exit status 0 on backup and invocation errors; need to distinguish warnings from errors #2364.

I can see how relica can charge so much given the gap between what restic provides and what I’d consider to be a robust solution. Still, I soldier on…

I have already solved my first 2 points above.

  • For (3), I’m thinking start /low restic ... This seems to pop up a new window however. Any ideas?

  • How do you ensure that you don’t run a self-update while a backup is running?

  • How do I log to the system log on a non-0 exit status?

  • Thanks for the lead re blat and email. How do you capture Window’s STDOUT and STDERR for blat’s consumption?

A post was split to a new topic: Potential Windows installation documentation issue