Config items like vswitch, vnic, MTU settings, kernel interfaces and various other settings would be lost if the host fails. Re-building a host manually, especially hosts with complex network configurations would take some time.
The script connects to each host specified in a list and retrieves the VMware product version and build number prior to taking a backup. The filename for the backup includes the ESXi hostname, product, build number and date/time. Restoring a configuration requires the new host to be running the same version and build number as the host that the configuration was taken from. There is an option to use a ‘–force’ switch in the restore command if the build number is different but its not VMware supported.
At the time of writing this post my hosts were running vSphere 6.5. The script was executed from Ubuntu with VMware vCli installed
The script includes a section to copy the backup files to a TFTP server if desired. One of the hosts being backed up homes the Ubuntu VM that executes the script. I wanted a simple way to archive the backup files off the VM and ultimately off the host. In my lab a Synology NAS provides storage and various services including a TFTP server. You can simply remove the TFTP section from the script if not required.
If you plan to use crontab to execute the script you might be interested in a previous post I wrote:
Only execute this script on a dedicated management network or over a VPN as TFTP is not encrypted.
The script backs up the host configuration only, it does not backup the VM’s running on the host. You will need another backup solution for the VM’s.
You can find the VMware ESXi Host Backups Python Script script on GitHub. In the next post I’ll detail how to restore the configuration to a host.