If you are a Vault administrator you probably aren't receiving any status notifications from Vault regarding scheduled backup routines. If you are, then the notifications probably come to you via email using a custom script or application. Outside of third party server backup tools, this has been typical for Vault backups. What I have been increasingly faced with is administrators that don't want more emails. From anywhere. A Vault backup email notification, while important, is probably sent once each day (every time a backup is run) and hopefully it's just a note on a successful backup. You begin to see the issue; these emails quickly get ignored and lost in a sea of daily email messages. So putting aside email messages what is a better way to be notified of this critical information? How about a text message or a push notification?
In many ways email is passé when it comes to things like reports & notifications, and rightly so. Much of what once had to be sent by email is now sent via a short notification to your phone (or a notification center). They can be seen at a glance and dismissed just as quickly. Wouldn't it be nice if Vault could do that too? Well, the good news is that using Powershell & IoT (Internet of Things) it can! Better yet; it probably won't cost you anything.
You can check out my previous blog: Supercharge Vault Administration with Powershell! which could be considered part one to this post.
To get Vault backup notifications via your phone or tablet you will need to use a scheduled Powershell backup script. This script will post some key information via something called a webhook to IFTTT or Zapier. This webhook triggers an action using one of these IoT services. The service will then forward the information to your phone via a push notification or a text message. Let's dive in.
Step 1: Create an Account
The first thing you'll want to do is register an account with either IFTTT (If This Then That) or Zapier. If you haven't heard of either of these services then head on over to their websites and take a look at what they offer. In short, they automate online activities by watching for events that trigger an action. There are thousands of examples of what these services can do but one example is this blog itself. I have an IFTTT applet that automatically posts blog entries I author here, to my LinkedIn profile. Pretty slick, but that doesn't even scratch the surface of what can be done.
Which service you use is up to you. Both have free account options that are enough for this application with Vault. The major difference between the two is that IFTTT is geared for internet enabled consumer devices and services like thermostats, lights, appliances, and social media. Zapier, on the other hand, is geared toward business tools and can connect to CRM software, SQL Server, AWS, and social media, etc. I'm going to use IFTTT in this post but I've also tested this with Zapier and both work just fine. A third option is Microsoft Flow but you'll need a paid license to use it in this case.
Step 2: Create a Webhook Trigger
Whichever service you use you need to create a webhook trigger. Once you setup a webhook you should receive a URL that is unique to your account (the unique URL means you don't need login credentials to pass information to the IoT service). This webhook URL can be placed in your backup script and will be able to send small bits of information that you'll want to see in the notification. The webhook will look similar to this when you create it:
Step 3: Create a Notification Action
Still on IFTTT/Zapier we need to create an action. For our purposes here I'll create an SMS notification to send a text message to my phone but there are hundreds of possible actions to choose from. If you are using IFTTT you could send a push notification to the app instead of a text message (Zapier has no phone app). More Intriguing options might be to blink a light for a backup failure or perhaps automatically add some data points like size and duration to a SQL table used for reporting. There are some interesting possibilities, to be sure.
Step 4: Add the Webhook Address to the Powershell Backup Script
Once the Applet (IFTTT) or Zap (Zapier) is finished we can add the webhook URL provided to the Powershell backup script and use the Invoke-RestMethod commandlet to fire the webhook and send the data for our trigger.
There are all kinds of data points we can extract using a Powershell backup script if you want to add some stats to your notification. I have added the backup size, available drive space, and backup duration as well as a subject to my notification. The subject indicates a backup success or failure. These variables are all set earlier in my script which is part of the reason it's over 200 lines. You certainly don't need a script that long to get IoT notifications working.
With IFTTT the data after value1 & value2 in the script gets included in the notification based on the ingredients we selected above when creating the applet. Looking at the image below you can see where the webhook URL is placed, where the variables are set and then the commandlet that runs to send the webhook to IFTTT.
Depending on where you have placed the webhook in your backup script it will trigger the notification you've configured from the IoT service. If you don't want daily notifications you could put the webhook inside a conditional statement that only sends the webhook if a backup fails. Here is the SMS notification message I received after running my Vault Backup task.
I hope this peaks your interest in what might be possible with Vault, Powershell and IoT. If this is something you are interested in implementing or adding with your next Vault upgrade feel free to reach out to me.