Automated Restic Backup, Forget, Check with PowerShell Script on Windows and Linux

Hi there,

I’ve moved from Duplicati to Restic, and except the learning curve, it’s very great!

In order to backup every day my devices, I’ve created this set of script with PowerShell that can work on Windows and Linux. It also send pings & logs to HealthChecks.io, a great cron monitoring site.

I cannot guarantee that it’ll work for you, but maybe it’ll help! :blush:

5 Likes

Hello @Chouffy sorry if it is a very basic question but if I only want to add the Log, what would be the syntax? (Windows)

I’m currently running something like this:

$url = "https://hc-ping.com/aabdxxxxxxxxxxxxxxxxxxxxxxxxxx"
PowerShell Invoke-WebRequest -Uri $url -Method GET

I obtain the text file with the report by adding
> report.txt
at the end of the restic command

but I don’t know how to add that report.txt file to the HC log

Solved!
In case it helps someone else:

$Body = foreach($line in Get-Content report.txt) {
    if($line -match $regex){
        # Work here
	$line + "`r`n"
    }
}

Invoke-RestMethod -Uri https://hc-ping.com/MyIDHere -Method Post -Body $Body