Send Veeam Backup notifications to Discord!
github.com/tigattack/VeeamDiscordNotificationsPosted Dec 7, 2018, 1:10 AM UTC
Posted Dec 7, 2018, 1:10 AM UTC
I hope it's OK to post this here, I wasn't sure so I thought I'd give it a shot. Sorry if it isn't, mods.
Here's my tutorial to get it running.
This project started when I originally forked the project from this and made a number of my own improvements.
Note: I also have Slack and MS Teams versions on my GitHub. The MS Teams version is a bit out of date, but I'll be working on that soon.
I've now updated the way the script structures the reports to Discord (using embeds now, looks a lot nicer) and decided to split it off into it's own repo, instead of showing you guys how to use a workaround to get my original fork working with Discord.
I did this because the changes I've made are unlikely to be compatible with Slack, and I don't currently have the time to investigate Slack's documentation, so I made the decision to release this separately so you guys can enjoy it without having to wait months for me to probably just get frustrated and do the same thing :P
This project has been a lot of fun for me, though not without frustrations of course, as all projects go. I've learnt a lot and really enjoyed it. I hope you lot can enjoy it as much as I have.
All feedback is appreciated!
Nifty
howdy tigattack,
neat! i can't use it, but it reads well and i can understand most of it. [grin]
other than the nasty, icky aliases, i've only noticed 3 things ...
[1] VeeamDiscordNotifications/DiscordVeeamAlertSender.ps1 at master · tigattack/VeeamDiscordNotifications — https://github.com/tigattack/VeeamDiscordNotifications/blob/master/DiscordVeeamAlertSender.ps1#L10
on that line you read in the text file, join resulting array items with newlines, and then feed it to the JSON converter.
did you know there is a -Raw parameter for Get-Content? [grin] that would save the "glue it back into one string" fiddling.
[2] IF/ELSEIF/ELSE cascades @ 37, 63
those could be done with a switch & be easier to read/maintain.
[3] opportunity for a function
item [2] above looks like a prime candidate for a function. that "get the best unit abbr" thing is pretty common. you would likely reuse such a function in the future.
take care,
lee
Hey, cheers Lee. Good to have your appraisal!
other than the nasty, icky aliases
Heh, Linux and DOS habits die hard. I'll fix that just for you though :P
did you know there is a
-Rawparameter forGet-Content?
That's dope, I did not. So I should replace line 10 with the following?
$config = (Get-Content -Raw "$PSScriptRoot\config\conf.json") | ConvertFrom-Json
IF/ELSEIF/ELSE cascades
[...]
opportunity for a function
I've had a few people say this would be better as a switch. I think that may have to be moved up my to-do list.
I'm not sure how I'd create a function for that if I'm honest, but I will look into it.
Thanks :)
Edit: correcting myself.
howdy tigattack,
you are most welcome! glad to help a tad ... [grin]
[1] aliases
they are there for a reason ... for quick-n-dirty use at the command line. they are a really bad idea for anything that you may need to maintain, tho. it's too danged easy to forget what they do ... [blush]
[2] Get-Content & -Raw
yup, that otta work. if it's already a JSON string, then feeding it directly to ConvertFrom-JSON is the usual way to do it, from what i have read. i rarely use JSON with my 1-system setup. [grin]
[3] switch and function demo
i've helped with that specific idea a couple of times and have two different functions for getting unit size stuff. here's one ...
[PowerShell] function ConvertTo-ByteUnits - Pastebin.com
— https://pastebin.com/srN5CKty
if you wanna look at the other, go to my main pastebin page - it's one of the 1st two listed right now.
take care,
lee
This is awesome, nice work! I just switched over all my services to notify via Telegram (coming over from Pushbullet).
Has anyone setup notifcations with Veeam/etc and Telegram?
EDIT- looks like Telegram has some support for Slack notifications.. I will see if I can adapt your code for this. Thanks for the inspiration!
DOUBLE EDIT I wanted to add, nice work on the blog and script documentation!!
Nice man, let me know how your work on this goes. Happy to help out with anything :}
Appreciate that bud, I'm pleased with it too tbh😄 Slowly but surely building some good content onto my blog.
Cool, found some examples, will post some code once I get a working script. Thanks!!