Comprehensive data protection for all workloads
Post Reply
jonc
Novice
Posts: 9
Liked: never
Joined: May 19, 2015 1:47 pm
Contact:

Backup Success/Failed Notifications to Slack

Post by jonc »

Hi all,

Tried looking around but found zero articles related to this. We'd like to push Backup Success/Failed notifications to Slack. The way we're doing it now is to run a post backup bat file that pushes a curl command to slack and that works fine for static messages. The problem here is that if the backup fails, we wouldn't know. Message still pops up to slack that the job has been completed. Is there a way to push a curl command, or hack something from Veeam to get these working? All we need is the Job Name followed by Success/Failed.

Thanks!
foggy
Veeam Software
Posts: 21069
Liked: 2115 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by foggy »

You can check the job status via PowerShell prior to sending the message.
dellock6
Veeam Software
Posts: 6137
Liked: 1928 times
Joined: Jul 26, 2009 3:39 pm
Full Name: Luca Dell'Oca
Location: Varese, Italy
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by dellock6 » 1 person likes this post

You can trigger IFTTT for this, just send the job report to IFTTT and use than the Slack support in it to write results into Slack.
Actually this is something pretty cool to try out, let me know if it works!
Luca Dell'Oca
Principal EMEA Cloud Architect @ Veeam Software

@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
dellock6
Veeam Software
Posts: 6137
Liked: 1928 times
Joined: Jul 26, 2009 3:39 pm
Full Name: Luca Dell'Oca
Location: Varese, Italy
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by dellock6 » 2 people like this post

just did a quick tests, seems we can have something funny with Slack, thanks for the nice idea :)

Image
Luca Dell'Oca
Principal EMEA Cloud Architect @ Veeam Software

@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
jonc
Novice
Posts: 9
Liked: never
Joined: May 19, 2015 1:47 pm
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by jonc »

Any way of doing this without have to use third parties? I'm a bit wary of sending Backup Job emails to IFTTT.
dellock6
Veeam Software
Posts: 6137
Liked: 1928 times
Joined: Jul 26, 2009 3:39 pm
Full Name: Luca Dell'Oca
Location: Varese, Italy
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by dellock6 »

The only ways I know are using internet automation solutions, being it IFTTT or another one. The only way to do it directly probably is to write some restful code that takes job reports and post it to slack using their APIs.
IFTTT just takes an email and posts it to slack, nothing is stored into it as far as I know.
Luca Dell'Oca
Principal EMEA Cloud Architect @ Veeam Software

@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
kylemartin901
Novice
Posts: 6
Liked: 2 times
Joined: Nov 13, 2011 9:37 pm
Full Name: Kyle Martin
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by kylemartin901 » 1 person likes this post

Hi,

We have implemented Slack notifications for failing jobs. To do this we implemented our solution using VeeamOne based on the Solarwinds Orion and Slack integration (Video: https://thwack.solarwinds.com/docs/DOC-188202, Detailed Document: https://thwack.solarwinds.com/docs/DOC-188108).

1. Configure a webhook on the Slack channel you want alerts to be delivered to
2. In Veeam One add a Run Script to the action on the alarms you want to send to Slack
3. Configure the Run Script action to run a Powershell script that takes in the Veeam One arguments and sends them to Slack (https://www.veeam.com/kb1552)

This is a ruff outline of the Powershell script we use

Code: Select all

# Define params to keep it clean when called by the Veeam One Alert
param([string[]]$Caption,[string]$Status,[string]$Details,[string]$Node)

# Set the webhook endpoint on Slack, and format a tight datestamp
$webhook = ‘your_slack_webhook_key'
$ftime = Get-Date -format “yyyy.MM.dd@HH:mm:ss”

# Set an emoji for specific status
$emoji = ‘’ # default empty
switch ($Status)
{
    Unknown {$emoji = ‘:thought _ balloon: ‘}
    Warning {$emoji = ‘:angry: ‘}
    Success {$emoji = ‘:green_heart: ‘}
    Error {$emoji = ‘:fire: ‘}
}

# build the JSON payload for the web request
$slackJSON = @{}
$slackJSON.channel = ‘your_slack_channel’
$slackJSON.username = ‘your_slackbot_name’
$slackJSON.icon_url = 'your_slackbot_image_url’

# Munge together the Slack formatted text string, (See Slack API page for details)
$slackJSON.text = $emoji + ‘ - `’ + $Caption + ‘` status changed to *’ + $Status + ‘*’ + “`n” + ‘*Details:* ’ + $Details + "`n" + '*Node:* ' + $Node + “`n”

# Build the web request
$webReq=@{
    Uri = $webhook
    ContentType = ‘application/json’
    Method = ‘Post’
    body = ConvertTo-Json $slackJSON
}

# Send it to Slack
Invoke-WebRequest @webReq
# Uncomment the following line(2) to debug the final send
# write-output $slackJSON
# write-output $slackJSON.body
We then set the Run Script action on the Veeam One alarms we want to be sent to Slack like below

Code: Select all

Powershell.exe -File C:\Scripts\SlackVeeamOneAlertSender.ps1 -Caption %1 -Status %5 -Details %3 -Node %2
I hope this helps those that want Slack notifications from Veeam
markea
Lurker
Posts: 1
Liked: 2 times
Joined: Aug 13, 2016 3:46 am
Full Name: Alex Markessinis
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by markea » 2 people like this post

I worked out a script that works with Backup and restore, I based some of the code off the code that kylemartin901 posted thanks man. I've pushed it all up to github, feel free to make use of it or contribute https://github.com/TheSageColleges/Veea ... ifications cheers!
derekdo
Lurker
Posts: 1
Liked: never
Joined: Apr 07, 2014 4:48 pm
Full Name: Derek Dolan
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by derekdo »

This is perfect, right down to the instructions. I'm a slack noob and this made it very easy to implement.
MichaelCade
Veeam Software
Posts: 314
Liked: 74 times
Joined: Mar 23, 2015 11:55 am
Full Name: Michael Cade
Location: Cambridge, United Kingdom
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by MichaelCade »

I found this today that may be of use here also - https://github.com/TheSageColleges/Matt ... ifications this leverages PowerShell to then send to Slack, there is also a link to anyone using mattermost for similar operations.

I am not the author of this.
Regards,

Michael Cade
Global Technologist
Veeam Software
Email: Michael.Cade@Veeam.com
Twitter: @MichaelCade1
MichaelCade
Veeam Software
Posts: 314
Liked: 74 times
Joined: Mar 23, 2015 11:55 am
Full Name: Michael Cade
Location: Cambridge, United Kingdom
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by MichaelCade »

also this https://github.com/dgacias/veeam does something very similar.

once again I am not the author of these.
Regards,

Michael Cade
Global Technologist
Veeam Software
Email: Michael.Cade@Veeam.com
Twitter: @MichaelCade1
dellock6
Veeam Software
Posts: 6137
Liked: 1928 times
Joined: Jul 26, 2009 3:39 pm
Full Name: Luca Dell'Oca
Location: Varese, Italy
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by dellock6 »

Or if you don't want to write a single line of code:

https://www.virtualtothecore.com/en/sen ... -to-slack/

Luca
Luca Dell'Oca
Principal EMEA Cloud Architect @ Veeam Software

@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
mrbios
Lurker
Posts: 2
Liked: never
Joined: Nov 18, 2017 5:36 am
Full Name: Joel
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by mrbios »

i was looking into getting Veeam backup alerts into Slack and came across this thread... not sure if they are better ways of doing this but i found a slack app for emails.

i am a newbie so wanted something simple... basically create a channel in slack and assign it a unique slack email and fwd any emails you want and it will import that email into the channel...

no 3rd party apps etc required....

https://slack.com/intl/en-au/slack-tips ... l-to-slack
HannesK
Product Manager
Posts: 14287
Liked: 2877 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by HannesK »

Hello mrbios,
and welcome to the forums. Yes, your idea was mentioned one post before you by Luca :-)

Best regards,
Hannes
mrbios
Lurker
Posts: 2
Liked: never
Joined: Nov 18, 2017 5:36 am
Full Name: Joel
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by mrbios »

@hannesk
Luca's post was talking about ifttt and you had to use gmail or office 365 to push to slack (on-prem exchange isnt supported), maybe i am blind but couldn't see the direct slack email option..:)
Iain_Green
Service Provider
Posts: 158
Liked: 9 times
Joined: Dec 05, 2014 2:13 pm
Full Name: Iain Green
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by Iain_Green »

FYI for anyone not wanting to use ifttt since they have now gone PRO.
https://zapier.com/ is free and works great.

I now have my home PC sending emails to gmail which then trigger straight to my discord server!
This will work with Veeam / Veeam Agent.
Many thanks

Iain Green
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 145 guests