vCenter ESXi Config Backup Script

vCenter ESXi Config Backup Script

When using VMware vCenter, you may only occasionally need a configuration backup of each VMware ESXi host. However, there are some situations where having a config backup of each ESXi host is nice to have.

I didn’t want to back up each ESXi host manually, as it doesn’t scale well. Instead, I created a PowerShell script called vCenter ESXi Config Backup to do everything for me.

You can find the script on my GitHub. https://github.com/thedxt/VMware#vcenter-esxi-config-backup

Prerequisites

How It Works

The vCenter ESXi config backup script connects to VMware vCenter, uses vCenter to connect to each ESXi host, and takes a configuration backup for each host. Because the script uses vCenter, you don’t need to enable SSH on any of the ESXi hosts for the backup to work.

By default, the vCenter ESXi config backup script assumes you are not connected to vCenter and will prompt you to connect to vCenter. You can suppress this behavior if you are already connected to vCenter by setting the optional parameter named connected to the value of Yes.

The script checks to see if the backup folder you defined exists. If the folder does not exist, the script will create it.

Next, the vCenter ESXi config backup script enumerates all of the ESXi hosts in vCenter, it connects to each one and takes a configuration backup. The script outputs the backup into the folder you defined.

Once the backup is completed, the script renames the backup file to include the ESXi hostname, the ESXi installed version, the ESXi build number, and the backup date.

To use the script, you must provide it with a few parameters. The first parameter is vcenter, followed by the FQDN of your vCenter. The second parameter is folder, followed by the location where you want the ESXi config backups saved.

You will be prompted to log in to vCenter unless you suppress it with the optional parameter connected followed by the value of Yes.

Here’s an example of what the command should look like esxi-conf-backup -vcenter "vcenter.contoso.com" -folder "C:\ESXi-Backup"

Here’s the example output from that command.

vCenter Config Backup output

Here’s an example of what the command should look like if you are already connected to vCenteresxi-conf-backup -vcenter "vcenter.contoso.com" -folder "C:\ESXi-Backup" -connected Yes

Here’s the example output from that command.

vCenter Config Backup output when already connected to vCenter

If you ever need to restore the backup my blog post, ESXi Config Restore covers how to do that.

Exit mobile version