Backup Success/Failed Notifications to Slack

Availability for the Always-On Enterprise

Backup Success/Failed Notifications to Slack

Veeam Logoby jonc » Thu Jul 30, 2015 12:59 pm

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!
jonc
Novice
 
Posts: 9
Liked: never
Joined: Tue May 19, 2015 1:47 pm

Re: Backup Success/Failed Notifications to Slack

Veeam Logoby foggy » Thu Jul 30, 2015 1:44 pm

You can check the job status via PowerShell prior to sending the message.
foggy
Veeam Software
 
Posts: 15078
Liked: 1110 times
Joined: Mon Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson

Re: Backup Success/Failed Notifications to Slack

Veeam Logoby dellock6 » Thu Jul 30, 2015 8:21 pm 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
EMEA Cloud Architect @ Veeam Software

@dellock6
http://www.virtualtothecore.com
vExpert 2011-2012-2013-2014-2015-2016
Veeam VMCE #1
dellock6
Veeam Software
 
Posts: 5111
Liked: 1355 times
Joined: Sun Jul 26, 2009 3:39 pm
Location: Varese, Italy
Full Name: Luca Dell'Oca

Re: Backup Success/Failed Notifications to Slack

Veeam Logoby dellock6 » Thu Jul 30, 2015 11:03 pm 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
EMEA Cloud Architect @ Veeam Software

@dellock6
http://www.virtualtothecore.com
vExpert 2011-2012-2013-2014-2015-2016
Veeam VMCE #1
dellock6
Veeam Software
 
Posts: 5111
Liked: 1355 times
Joined: Sun Jul 26, 2009 3:39 pm
Location: Varese, Italy
Full Name: Luca Dell'Oca

Re: Backup Success/Failed Notifications to Slack

Veeam Logoby jonc » Tue Aug 04, 2015 10:32 am

Any way of doing this without have to use third parties? I'm a bit wary of sending Backup Job emails to IFTTT.
jonc
Novice
 
Posts: 9
Liked: never
Joined: Tue May 19, 2015 1:47 pm

Re: Backup Success/Failed Notifications to Slack

Veeam Logoby dellock6 » Wed Aug 05, 2015 4:46 pm

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
EMEA Cloud Architect @ Veeam Software

@dellock6
http://www.virtualtothecore.com
vExpert 2011-2012-2013-2014-2015-2016
Veeam VMCE #1
dellock6
Veeam Software
 
Posts: 5111
Liked: 1355 times
Joined: Sun Jul 26, 2009 3:39 pm
Location: Varese, Italy
Full Name: Luca Dell'Oca

Re: Backup Success/Failed Notifications to Slack

Veeam Logoby kylemartin901 » Wed Apr 20, 2016 4:17 am 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
kylemartin901
Service Provider
 
Posts: 6
Liked: 2 times
Joined: Sun Nov 13, 2011 9:37 pm
Full Name: Kyle Martin

Re: Backup Success/Failed Notifications to Slack

Veeam Logoby markea » Sat Aug 13, 2016 3:55 am 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!
markea
Lurker
 
Posts: 1
Liked: 2 times
Joined: Sat Aug 13, 2016 3:46 am
Full Name: Alex Markessinis

Re: Backup Success/Failed Notifications to Slack

Veeam Logoby derekdo » Thu Mar 16, 2017 2:03 pm

This is perfect, right down to the instructions. I'm a slack noob and this made it very easy to implement.
derekdo
Lurker
 
Posts: 1
Liked: never
Joined: Mon Apr 07, 2014 4:48 pm
Full Name: Derek Dolan


Return to Veeam Backup & Replication



Who is online

Users browsing this forum: Bing [Bot] and 41 guests