Availability for the Always-On Enterprise
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 » 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!

foggy
Veeam Software
Posts: 16836
Liked: 1361 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: Backup Success/Failed Notifications to Slack

Post by foggy » Jul 30, 2015 1:44 pm

You can check the job status via PowerShell prior to sending the message.

dellock6
Veeam Software
Posts: 5488
Liked: 1510 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 » 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/en/
vExpert 2011-2012-2013-2014-2015-2016-2017-2018
Veeam VMCE #1

dellock6
Veeam Software
Posts: 5488
Liked: 1510 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 » 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/en/
vExpert 2011-2012-2013-2014-2015-2016-2017-2018
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 » 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.

dellock6
Veeam Software
Posts: 5488
Liked: 1510 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 » 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/en/
vExpert 2011-2012-2013-2014-2015-2016-2017-2018
Veeam VMCE #1

kylemartin901
Service Provider
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 » 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

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 » 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!

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 » 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.

MichaelCade
Veeam Software
Posts: 210
Liked: 37 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 » Dec 05, 2017 2:16 pm

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: 210
Liked: 37 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 » Dec 06, 2017 7:36 am

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: 5488
Liked: 1510 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 » Dec 11, 2017 1:46 pm

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

@dellock6
http://www.virtualtothecore.com/en/
vExpert 2011-2012-2013-2014-2015-2016-2017-2018
Veeam VMCE #1

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], bpayne, simcomit, suprnova and 52 guests