WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Managing VM snapshot retention policies using the VMware Event Broker Appliance (VEBA)

Managing VM snapshot retention policies using the VMware Event Broker Appliance (VEBA)

10.28.2021 by William Lam // 2 Comments

vSphere Snapshots is an amazing technology that has enabled our customers to do so many amazing things from application lifecycle and testing to operating system updates and many other use cases. Like any technology, if it is miss-used, the benefits can quickly turn into challenge or nightmare.

As Peter Parker once said, "With great power comes great responsibility" which I think is one way to summarize VM snapshot usage 😆


I am pretty sure that every VI Admin out there has at least one story about vSphere snapshots gone wrong. Due to the convenience, ease of use and some times miss-understanding of how vSphere snapshot works, it can lead to a number of issues including filling up your storage and impacting other running workloads.

Now, imagine if you could implement a snapshot retention policy for your VM(s) based on the size of a given snapshot or maybe the number of days the snapshot has existed? Would that not be cool!?

This was actually an idea I had been thinking about and after a discussion with my colleague Michael Gasch, I realized we can easily do so with a bit of event-driven automation using our VMware Event Broker Appliance (VEBA) solution to run scheduled job for managing snapshot policies for a set of VM(s). Knative, which is the underlying backend technology that powers VEBA has an event source called PingSource, that can help with this type of use case.

Just like you have an event from vCenter Server or VMware Horizon, where VEBA subscribe to and then run a function, a PingSource is an event that is produced with a fixed payload running on a cron schedule that can then run some function or code. Using this information, I was able to build a basic PowerCLI function that can be used to manage VM snapshot retention based on age of a snapshot and/or the size of a given snapshot. This function can be deployed to monitor a set of VM(s) and can have different policies and/or schedules and a really cool capability of Knative when needing to run scheduled functions.

For more details on how to deploy and set this up in your own environment, check out the VEBA github example function. This is provided as an example, you can certainly create a more advanced function to evaluate other criteria's before deleting a given snapshot including sending a Slack or Microsoft Teams notification prior to snapshot removal.

More from my site

  • VM snapshot retention-based removal in vSphere 8.0 Update 3
  • VMware Event Broker Appliance (VEBA) v0.8.0
  • Preserving VM snapshot hierarchy across vCenter Servers
  • NSX Alarms in vCenter Server using vSphere Events in vSphere 8
  • Heads Up - Potential missing vCenter Server Events due to sequence ID overflow

Categories // Automation, vSphere Tags // snapshot, VMware Event Broker Appliance

Comments

  1. *protectedBill Akins says

    10/29/2021 at 2:23 pm

    Hi William,
    Great work as usual! I got so sick of snapshot sprawl that I wrote a snapshot maintenance PS script that is keyed on snapshot names and dates, and it runs nightly. It will send an email to the system contact the day before snapshots are deleted, in case there is a business need to retain them longer. If so, the snapshot can be renamed. I like your idea of a Teams notification, I'll work on adding that function.
    You can take a peep here:
    https://github.com/bakins929/SnapshotMaintenance
    Thanks for your great articles!

    Reply
    • William Lam says

      10/29/2021 at 2:37 pm

      Thanks and look forward to seeing function Bill

      Reply

Thanks for the comment!Cancel reply

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

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • VMUG Connect 2025 - Minimal VMware Cloud Foundation (VCF) 5.x in a Box  05/15/2025
  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...