Script to send report on Windows (I can't find one on the forum)

Hello, I鈥檓 new on restic and learning by myself and with this forum :smile: but I swear I didn鈥檛 find a single script in the whole forum. I am looking for how to send an email with the report on Windows.

Send-MailMessage is obsolete?

I was able to solve the creation of automated backups in Windows using the Task Scheduler but I need to be able to receive a report by mail.

Also I read Restic Backup Report 路 Issue #2341 路 restic/restic 路 GitHub so I think we need to solve outside of restic. I only need some guidance or start point.

It is rather question regarding your operating system not restic which does not do everything indeed:)

I do not know much about Windows but google has many answers e.g.:

This should give you good start point.

1 Like

Thanks a lot. I will check the link and post the feedback.

This was just an example - one of the first 3 top results when I typed question in google. You can check it or/and find something more suitable for your needs. It is not restic forum problem how to send email on my OS:) restic does not have sending email functionality today. It has to be solved outside. I can say I wanr to receive Telegram alert when my backup finishes. Or my desk lights to flash.

1 Like

I know and I understand. But as a backup solution, lacking those features is a big drawback because many users end up using solutions like Duplicati that have that part well integrated. Even if Duplicati have other problems too.

Greetings

1 Like

I recommend using resticprofile with webhooks sent to https://healthchecks.io/

1 Like

Thanks a lot for the info. I will check the links, but I work only on Windows and I think https://healthchecks.io/ is only for Linux

It is a SaaS service. It notifies when a web hook that should have been received is missed. You set your backups to send a hook when they are successful or not and they will notify you.

It has nothing to do with Linux don鈥檛 be scared :flushed: :laughing:

1 Like

Understood! Thank you so much. Now I鈥檓 a little less scared. :rofl:

I just changed the Windows policies for script execution, we鈥檒l see how the story goes

Solved with PowerShell鈥檚 script and Task Scheduler!

Thanks @kapitainsky

1 Like

you could post your scripts if you want - so the next user would find something in the forum. :wink:

1 Like

Sure @AlBundy !

Script for sending the restic report by email

#Date
$Date = Get-Date -Format "dddd dd/MM/yyyy"

#Define the email properties
$From = "senderemail@mail.com"
$To = "wheretosend@mail.com"
$Subject = "Restic Backup My Windows 10 Home Computer: " + $Date
#Load the restic report in the body of the email, reading it line by line and manually adding the line breaks
#Note: resticreport.txt is the result of a backup like:
#restic -r rclone:backup:restictest --verbose backup "C:\MyFolder" --password-file "C:\restic\resticpassword.txt" > c:\restic\resticreport.txt
#where > c:\restic\resticreport.txt create the file to send by email

$Body = foreach($line in Get-Content c:\restic\resticreport.txt) {
    if($line -match $regex){
        # Work here
	$line + "`r`n"
    }
}
 
#Define the SMTP server details for "senderemail@mail.com"
$SMTPServer = "smtp.youremailconfig.com"
$SMTPPort = 587
$SMTPUsername = "yourusername"
$SMTPPassword = "yourpassword"
 
#Create the email object
$Email = New-Object System.Net.Mail.MailMessage($From, $To, $Subject, $Body)
 
#Set the SMTP client details and send the email
$SMTPClient = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SMTPUsername, $SMTPPassword)
$SMTPClient.Send($Email)
1 Like

When I used restic on Windows I had my whole backup automated in PowerShell and I used this project to send updates via Pushover. Worked very well.

1 Like

Thanks a lot @donisewell ! I will take a look.