Remotely starting backups on Windows boxes

Updated version using group policy can be found here.

So I needed a way to back up user data without having to manually set up Restic on each box. I was running Restic on my box, specifying remote paths to backup, but I found that Restic seemed to re-read everything on every single backup, which was painfully slow.

I tried using psexec but ran into issues. This “fork” of psexec, called paexec, seemed to work perfectly, though. So, if you have multiple Windows boxes, try this out:

@ECHO OFF

ECHO Starting remote backup jobs, please wait…

paexec \\server1 -u domain\domain_admin -p password123 -e -c -f -d -background -csrc “\\public\backup\restic.exe” restic.exe backup -r \\path-to-repo --password-file \\public\backup\password.txt --cleanup-cache “C:\data1” “C:\data2”`

paexec \\server2 -u domain\domain_admin -p password123 -e -c -f -d -background -csrc “\\public\backup\restic.exe” restic.exe backup -r \\path-to-repo --password-file \\public\backup\password.txt --cleanup-cache “C:\data1” “C:\data2”

paexec \\server3 -u domain\domain_admin -p password123 -e -c -f -d -background -csrc “\\public\backup\restic.exe” restic.exe backup -r \\path-to-repo --password-file \\public\backup\password.txt --cleanup-cache “C:\data1” “C:\data2”

This will essentially log into each box, copy restic.exe (forcibly), and run backups for server1, server2, and server3 simultaneously in the background, at the lowest priority.

EDIT: I figured out I needed the -e switch if “domain_admin” hadn’t logged in on the remote server before.

I think by using share permissions, I can make \\public\backup only accessible to domain_admin, and therefore hide the password from the end user, to boot!

I’ll probably eventually add email capabilities by adding “>C:\log.txt”" at the end of the command then calling this “sendemail.exe” utility I use. But that’s enough for one day.

It’ll look something like:

sendemail.exe -f user@domain.com -t me@domain.com -u Backup Log -s smtp.domain.com:587 -xu user@domain.com -xp password123 -o message-file=C:\log.txt

I’ll edit this if I implement it successfully. That’s the code I use to run it locally and send email alerts. Haven’t tried with paexec yet.

Downloads:
https://www.poweradmin.com/paexec/
http://caspian.dotconf.net/menu/Software/SendEmail/

1 Like

Hello @akrabu,

paexec and sendemail, nice! I keep saying that, at the breakneck rate Windows has been evolving, in 20 years or so it will have all the nice features we’ve been having in *ix OSes for the last 40 years already :wink:

Seriously, good guide. If the time comes that I have to set up such a thing for Windows (I hope not, but one never knows), it will come handy.

Cheers,
– Durval.

1 Like