Powershell WinBackupStatusBot is a Windows scheduled task to run a Powershell script whenever a necessary event appears in the windows event log system.
This Powershell script will parse the event log further to find the event that triggered the task configured and report when backup operation start, is finished, cancelled or interrupted with the error code.
You will get an instant message in Telegram messenger whenever successfully or unsuccessfully Backup operations try to do their job on your Windows Server or standard Windows 7+ installation.
That allows you to monitor backup operations on the go and is informed when the unsuccessful result will appear to become aware of something goes wrong in the system. You should check up your Backup logs to manually maintain malfunctions on your Windows machine in this case.
Briefly, look at the script's workflow is shown in the figure below for a clearer understanding of how it works on your Windows server.
- Windows Events engine continuously collect all the events rotating in the Windows machine with unique IDs and statuses
- Task Scheduler has a task with XML filter that is triggered when backup service doing its job
- Task Scheduler run Powershell WinBackupStatusBot script when a task is filtered with EventID related to Backup operations service
- Powershell WinBackupStatusBot script makes another series of requests to Windows Event Log system to filter this triggered task again to parse additional data like operation result, error codes, etc
- Powershell WinBackupStatusBot script pack that data, preparing the message and makes a webhook to send it to the Telegram server
- You getting notification based on message format in the Powershell WinBackupStatusBot script
- Story continuing until Task Scheduler has its active task for filtering.
Clone Powershell WinBackupStatusBot repository
-
Open Terminal.
-
Change the current working directory to the location where you want the cloned directory.
-
Type
git clone
and then paste the URL you copied earlier or paste it: https://github.com/zv09/WinBackupStatusBot.git$ git clone https://github.com/zv09/WinBackupStatusBot.git
More detail how to clone repository from GitHub you can find in the GitHub's docs section: Cloning a repository
-
Open PowerShell console as an Administrator role
-
Type there:
set-executionpolicy remotesigned
Set-ExecutionPolicy RemoteSigned
-
Then type Y (or A) and press Enter
This will allow you to run Powershell scripts in your Windows system
Generally, there are 3 files you need from repository for making things happen
- WinBackupStatusBotTracking.xml
- WinBackupStatusBot.ps1
- TelegramBotSettings-Example.ps1
- Open Windows Task Scheduler
- In the Task Scheduler tree right click to create a new folder, name it as "Tracking"
- In this "Tracking" folder Select "Import Task"
- Import the
WinBackupStatusBotTracking.xml
file - On the "General" tab, click on "Change User or Group" and select a local administrative user.
- On the "Actions" tab, ensure the parameter of the Powershell action points to the actual location of the WinBackupStatusBot.ps1 file
- Click OK and type the correct password for choosen user.
- Install Telegram on your device or use it already
- Find @botfather and start chat
- Type
/newbot
- Give your bot a wishful name... like MyBackupBot, etc...
- Give your bot a username... e.g. mybackupbot
- You will get a message from @BotFather contains creation status, bot URL and providing token to access the HTTP API: via string with letters and digits
YYYYYYYYYY:WWWWWWWWWWWWWWWWWWWWWWWWWWWWW-ZZZZZ
- Keep your token secure and store it safely
- Start a chat with your bot and type
/start
- Type a message for the bot like "Hi"
- Exit bot chat and create a Telegram Group conversation. Call it something with the name "Dev-Test" or any other
- Invite your bot to the group.
- Access the following page
https://api.telegram.org/bot<TOKEN>/getUpdates
with insertion your bot's TOKEN between < > and remove < > characters - Look for the IDs in the page you got. Normally the Group ID will be a numbers preceded by a minus sign. User ID is a positive.
- Open
TelegramBotSettings-Example.ps1
and edit it pasting Group or User ID on your choose. Copy and paste your token ID there. - Save
TelegramBotSettings-Example.ps1
as aTelegramBotSettings.ps1
file. This is neccesary for working the Powershell WinBackupStatusBot script corectly, couse it merge this data on its runtime.
- That's all
The script is useful when you have many Windows Servers in different organizations (installation sites) which are not part of the one Domain infrastructure. And on everyday use you need to be sure that's everything goes well.
Based on how the time for starting the Backup process is configured in your system, you will get statuses in the Telegram messenger. If in your Task Scheduler the Backup operation is configured to launch once a day, during the launch you will receive a message about the start and a message upon completion of the process with the execution status.
The script is gradually developing. I will add new features and functionality based on issues need to know about Backup operations.
Whether reporting bugs, discussing improvements and new ideas or writing extensions: Contributions to Powershell WinBackupStatusBot are welcome!
Here's how to get started:
Check for issues or open a issue or open a feature requests. Fork the repository on Github Create a new branch off the master branch. Write a test which shows that the bug was fixed or that the feature works as expected. Send a pull request to me and wait till it get merged.
Based on communication further I will add you to the Contributors list additionally if you wish.
Pages site will use the layout and styles from the GitHub's Jekyll theme.