01/02/2026
Backrest notifications via Telegram
I love restic, I use it on every my server and since the developers added the backup compression feature (previously it has only deduplication) I think it’s the best backup software exisisting.
Using restic on GNU/Linux is a piece of cake and the peace of mind, but on Windows it’s a total different story…
The thing the bothers me the most on Windows is the awful Windows task scheduler and the total absence of notifications (who the hell regularly take a look to the Windows Event Viewer?).
Fortunately there’s a solution for those problem, which is Backrest, a nice web frontend to the restic that brilliantly solves both problems.
In this post I would like to show a nice solution for backup notification using Backrest and Telegram, in this way you’ll get a Telegram notification using Backrest Hooks every time a backup is successful, returns a warning or an error.
First of all open Telegram and find a user called @BotFather
Start a chat with /start and create a new bot with the command /newbot
Give a name and a username to yourbot (for example Backrest Buddy and backrest_buddy)
BotFather will give you a reply like this, the most important information is the API token
Use this token to access the HTTP API: 1234235:069:AAHgPEM2HJIh2Ci1G1l345u2QbbCs876CA Keep your token secure and store it safely, it can be used by anyone to control your bot.
Open a browser and go to this url
https://api.telegram.org/bot<API TOKEN>/getUpdates
Then open Telegram, open a chat with your bot and write something to it, then get back to the browser and refresh the page, you’ll see some json output with a chat section with a chat id, copy that data, it’s the most important data with the API token.
Now create a powershell script (for example c:\Users\tas\backrest-buddy.ps1) with this syntax, just be careful to insert the API token and the chat id the right spots.
param(
[int]$ExitCode = 0
)
$BotToken = "<API TOKEN>"
$ChatId = "<CHAT ID>"
$HostName = $env:COMPUTERNAME
$Date = Get-Date -Format "dd-MM-yyyy HH:mm:ss"
if ($ExitCode -eq 0) {
$Text = "Backup OK`n------------------------------`n`nHost: $HostName`nDate: $Date"
} else {
$Text = "Backup FAILED`n------------------------------`n`nHost: $HostName`nData: $Date`nExit code: $ExitCode"
}
$Uri = "https://api.telegram.org/bot$BotToken/sendMessage"
$Body = @{
chat_id = $ChatId
text = $Text
parse_mode = "Markdown"
}
Invoke-RestMethod -Uri $Uri -Method Post -Body $Body
Now you can test the notification using this command for successfull backup (change the Powershell script path accordingly to your script)
powershell.exe -NoProfile -ExecutionPolicy Bypass -File c:\Users\tas\backrest-buddy.ps1 0
or this command for a failed backup
powershell.exe -NoProfile -ExecutionPolicy Bypass -File c:\Users\tas\backrest-buddy.ps1 1
If you receive Telegram messages from your bot for a successfull or failed backup everything works as expected.
Now one last step, let’s make Backrest use these powershell script to send us notifications.
Open your Backrest plan settings and go to the Hooks section.
Create three Hooks commands:
– on the first Hook choose CONDITION_SNAPSHOT_SUCCESS as condition
– on the secondo Hook choose CONDITION_SNAPSHOT_WARNING as condition
– on the first Hook choose CONDITION_SNAPSHOT_ERROR as condition
Now insert the same commands you used to test the Telegram notification as Hook commands:
– on the first Hook insert “powershell.exe -NoProfile -ExecutionPolicy Bypass -File c:\Users\tas\backrest-buddy.ps1 0”
– on the second Hook insert “powershell.exe -NoProfile -ExecutionPolicy Bypass -File c:\Users\tas\backrest-buddy.ps1 1”
– on the third Hook insert “powershell.exe -NoProfile -ExecutionPolicy Bypass -File c:\Users\tas\backrest-buddy.ps1 1”
Insert ON_ERROR_FATAL as Error Behavior on all the three hooks.
Ok you did it, now you only have to launch a backup and check your Telegram notifications, if you want to test a failed backup simply add a non existent path to the backup and launch it.


![[ Celebrate 30 years of GNU! ]](https://tasslehoff.burrfoot.it/wp-content/uploads/2013/11/GNU_30th_badge.png)

