VMware: Script to automated offline snapshot of vCenters in ELM mode
Let me tell you a quick story.
A while back, I was on a call with VMware support, working through a pretty standard issue. Nothing crazy, until the engineer dropped this simple question:
“Did you take an offline snapshot of your vCenter before proceeding?”
And just like that, I froze đ !
Offline snapshot? Of vCenter? Never even crossed my mind.
That one question stuck with me. After the call, I went digging. Turns out, it’s not just a good idea it’s actually recommended in KB 313886, especially when you’re running multiple vCenters in Enhanced Linked Mode (ELM).
Why This Matter
In large VCF environments, a bad upgrade or misstep can leave you with corrupted vCenters. Taking snapshots while the VMs are powered on might look fine, but you’re risking inconsistencies.
So, I asked myself: why isnât this baked into SDDC Manager already? Especially knowing that there’s already a feature request submitted for it VCF-I-2035?
Still donât have an answer to that. But I didnât want to wait around.
What I Built
I rolled up my sleeves and wrote a script. The goal? Make offline snapshots of vCenters in VCF environments a no-brainer.
Hereâs what it does:
- Connects to vCenter and SDDC Manager
- Finds all the vCenters VMs and all information that I need VMhost VMid âŠ
- Gets the ESXi credentials from SDDC Manager via API
- Turns on SSH temporarily from the vcenter
- Connect to ESXi and play with vim-cmd commands
- Powers off each vCenter
- Takes an offline snapshot
- Powers them back on
- Waits for them to come back online
- Cleans up by disabling SSH and closing sessions
Simple, safe, and something I now run before any critical update.
The script can be found on my GitHub here.
Use it, tweak it, break it but maybe test first!
Enjoy !