With the rise of ESXi I have often found myself simply redeploying the hypervisor in order to overcome an issue. Why? Because it literally takes minutes to reinstall ESXi and when you have a big customer being effected by an outage, your first priority is to bring the environment up. Yeah you still have HA and what not, but you still need to bring all the hosts in the cluster up and functional as soon as possible so that you dont find yourself in a situation where you have lost another host. Yes, I am all for finding the root cause but sometimes my curiosity is not as important as the customer’s application. In reality it never is. Plus what if your cluster just happens to be a two host cluster (dont ask me why, but I have seen that as well), in this case bringing the other host up is of paramount importance unless you dont mind being caught with pants down.
So let’s say you reinstall ESXi and that really takes a few minutes. However their might be things you do to customize your hosts like licensing info, multipaths, local users, switchs etc etc. I think you get the idea. Soon you will realize that its really stuff like this what ends up consuming your time. So what you do? In comes vMA. You can use vMA to backup your host configuration to a file and use that file to restore the changes you made to the host. This will save you plenty of time. Follow these simple steps.
Login into vMA and set the vifptarget to the server you want to back up. To do that run:
vifptarget -s servername/ip (This is assuming you have already added the server in question using the vifp addserver command — fast pass)
Once the target has been set
vicfg-cfgbackup -s /location/BackupFileName
Your host configuration is now saved.
If you dont want to do a vifp addserver and then set the target to this host in vMA for whatever reason, you can also run:
vicfg-cfgbackup -s -server IPaddrOfHost /location/BackupFileName (This command will prompt you for a username and pwd as the vMA appliance doesn’t have this. Note the -s stands for save).
You can then FTP or SCP into the vMA appliance and grab this configuration file and store it in a safe/accessible location. Notice I said “accessible” because its important for you to have backups, but these backups are not of any value if you can’t get to them when you need ‘em.
You can restore the configuration using the following command from your vMA appliance:
vicfg-cfgbackup -l -server IPaddrOfHost /location/BackupFileName (Note the -l stands for load)
You will be prompted for a username and password and you will also have to type YES as the prompt will say.
Keep in mind you will have to reboot your host after the restore completes.
Some use cases:
Let’s say you accidentally deleted a vswitch on your host. Instead of trying to replicate what another host has and increase your chances of missing a thing or two (maybe promiscuous mode was enabled as you run an IPS device on this host/cluster), you can simply use the above command to restore the backup for this particular host, restart your host and you are all set.
You decided to reinstall ESXi on the host. You will notice once you begin that process your host in vCenter will now be down. As you complete the install for ESXi and assign your host the static IP addr, you can then restore the config using the above commands and reboot your host. Log back into the vCenter and try to reconnect the host. The agent will get redeployed on this host and once that is completed, you will notice that all your settings are in place and DRS can happily move VMs on this host.
You can probably use powercli/vcli to do the same. My personal favorite is vMA although I use powercli/vcli for other things.