Backup those ESXi Host Configs
Have you ever found yourself in a position where youâre freaking out about needing to get an ESXi host back up and running after being forced to wipe the hypervisor from the boot device? No? Well I have. But, if youâre anything like me, youâve heard the three Bâs of being an IT professional. Backups, backups, and ummm... oh, backups!
Letâs give VMware a round of applause here. ESXi 5.0-5.5 is a very stable hypervisor. While Iâve only been working as a consultant for 3 years and change, Iâve only come across one instance where I HAD to wipe an ESXi host in order to get it back up.
The client had two ESXi hosts running on an HP custom iso with ESXi 5.1 in a cluster and they needed to be upgraded to ESXi 5.5. Okay, no big deal right? Just simply upgrade vCenter and then move on to upgrading the hosts. Well I learned something that day, while this flow chart from vHersey might be right 99% of time, you still need to be good little boy and girl scouts and do backups before you make changes.
Basically, in a nutshell, if you tried to upgrade the host regardless if you use the HP ISO or the VMware generic ISO, the install would fail around 20% and roll back was not possible. The environment was very simple so a fresh install, some changes to networking and setting up iSCSI was all that needed to get everything inventoried and running again.
But I got to thinking, what about people who have more complex configs on their hosts and donât have host profiles setup and for some reason are always making changes to the host configs? Well I thought this would be a good time to stretch my powershell legs and see what Iâm capable of. So I present to you, my âDaily ESXi Backup Scriptâ! Itâs quick and dirty, but it gets the job done if you ever find yourself needing to backup multiple host configs at one time.
Itâs a very basic script in that it will:
Load the powerCLI snap-in
Connect to your vCenter server with the credentials you define
Creates a folder with todayâs date
Exports all the configurations for all the hosts registered in vCenter to the folder and puts the results into a text document
Itâs not a complex script, but it gets the job done if youâre goal is to retain daily backups. I will keep working on this script to add some fancy things such as sending an email when itâs done, setting a retention period before getting rid of older backups and more.
So without further adieu:
Once I figure out how to post code to Tumblr and have it display the way I want, Iâll start posting directly here.