W10 PowerShell and Task Scheduler

Using Restic on Windows 10 can be scripted with PowerShell. The environment variables might have secrets so they can be stored in Credential Manager. The Task Scheduler can then run the script.

Here’s a link to a Gist of the PS script I’m using: Backup-Folders.ps1. It works for me!

Hey @Boggin and welcome to the restic community! :slight_smile:

Thanks for sharing your Windows PowerShell script with us.
As a little side note and hint: I would add some VSS to your script so that you can make sure that even locked files can be backed up by your script.
This was already discussed on the forum; doing a search here: https://forum.restic.net/search?q=windows%20vss

I don’t think I have seen the use of the credential manager in any of the .ps scripts posted/shared on the forum, so I think this is a great addition!

I’ll have to look into the credential part. A minor PowerShell function might be helpful is Stopwatch. This will allow a common file to contain info about elapsed times for backups. Have the backup times been going up or unexpectedly going down?
$sw = [Diagnostics.Stopwatch]::StartNew()
somesortofRestic command
$sw.Stop()
$LOGSTR = “The elapsed time for ${RESTIC_SOURCE_DRIVE} backup is {0:%h} hours {0:%m} minutes” -f $sw.Elapsed
# log the elapsed time
Add-Content -Path .\myresticoveralllog.log -Value “nr $LOGSTR”

I may start using Start-Transcript & Stop-Transcript, as I’m a bit of a newbee to PowerShell.