Hello, I’m new on restic and learning by myself and with this forum but I swear I didn’t 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.
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.
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.
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.
#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)