Powershell as glue for System Center Virtual Machine Manager (SCVMM) and VEEAM Backup & Replication

IT infrastructures and services management was and still is today an important part of my ‘business as usual‘ set of activities. Regardless of the tools and technologies implemented what I look for are always two features for monitoring and automation, simplicity and efficiency.

If monitoring is essential for having visibility on the overall infrastructure and for being proactive, automation is necessary for delivering consistent results in a timely manner especially in complex scenarios.

Any programming language is a secret weapon from complex monitoring or basic automation task, but as we all know… with great power comes great responsibility!  Every line of code needs to be tested and hopefully maintained for years to come and needs to survive to its own creator.

This article will mix a bit of product knowledge and few powershell lines of code with the aim of getting the best of both with the best results and no compromises.

After a few years of usage, I wanted to share my positive impressions on a couple of products Microsoft System Center Virtual Machine Manager(SCVMM)  and VEEAM Backup and Replication ( B&R – VeeamZip). These aren’t the only solutions for virtualisation and backup that I use, but for a number of reasons are the one that I use for this article, but you can easily modify this script to work with your backups solution.

VEEAM

I spoke about VEEAM before, there are a lot of valid competitors, but I’m really a fan and I love the simplicity of their products: https://www.scriptinglibrary.com/uncategorized/powershell-veeam-backup-and-replication-veeamzip/

SYSTEM CENTER VIRTUAL MACHINE MANAGER

I give for granted that you’re familiar with it and you’re currently using it. If that is not the case a good place to start is the official documentation:

I think VMM is a product that has a huge potential and with a really small effort be really the central management for your infrastructure.

If you manage from a few hundred to thousands of VM it will very hard to manage the manually without a centralized solution and good governance.

By governance, I mean a structured approach, processes, and workflows that will determine the lifecycle of a VM from the moment where it was provisioned and when will be potentially decommissioned. If System Center VMM offers templates to automate the provision of Virtual Machines and VEEAM can create a compressed backup of that VM these tools are performing independent tasks, separate configurations and separate reports.

How to Integrate SCVMM and VEEAM (or other tools)

I chose not to create a third tool for getting the visibility that I need because PowerShell is the common denominator of both tools or depend on a third-party tool for displaying a dashboard-like interface like Power BI for example.

Hyper V has no custom attributes for VMs, but via SCVMM you can add TAGs, Cost Center and any other meaningful field like owner, department, project, reference to other app or your own one like the JIRA ticket that started the automated or manual deployment, and like in this case when the ‘LastBackup’ was performed like in this example.

In VMM if you select one VM you can choose Custom Properties and Manage Custom properties and add “LastBackup”. That custom properties will be available for all your VMs, if you want to have an idea of the code you need to write you can also visualise the code clicking on the “View Script” button.

Now that you have your property for each VM you need to fetch the right information from the Backup solution. In this context, the source of truth can be a database or a filesystem. In my example, I chose the backup repository that is on a file share.

The backup files of VEEAM have a quite consistent naming convention, I said quite consistent because is changed over this couple of years.

For instance, if you list your server backup the format could be either of these:

  • YOURSERVERD2018-01-01T08300.vbk
  • YOURSERVERD2019-01-01T08300_XXXX.vbk

If in your repository you have multiple backup files filtering by file extension (.vbk) and removing all backups that are not completed (<22MB) is a good idea.

In my case, I’ve listed my list of full backups performed by VEEAM sorting by name in descending order,  storing the result into an hash-table and using a try-catch helped my to keep just the properties I need Name and DateTime for my Key-Value pair.

The result is a small script of 50 lines of code, simple to maintain and easy to customise or extend if needed.

According to your needs you can schedule to run this script to update your VMM properties as many times per day you want.

WRAP UP

Simple scripts or customisations don’t replace third-party tools (like VEEAM ONE in this case) or bigger managed solutions but can be exactly what you need with little o no maintenance required and can have quite a big impact on the result you can achieve using exactly the same tool.

As usual this script is available on my GitHub repository.

 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.