So, how do you backup and restore ESXi host configuration? Having a backup plan for your virtual machines is important but you can enhance resiliency of your virtual environment if the backup plan includes configuration of the actual ESXi host running the virtual machines. If a host crashes, it is matter of running a command and wait for server to come up with its original configuration. Its the difference between coming up within 5 minutes or 50 minutes. Vmware provides great tools to help us accomplish backup and restore from a command line (CLI).
What do you need?
- vSphere Management Assistant (vMA)
- SSH enabled on the host
I am going to assume you are familiar with vMA and how it functions and you have it deployed already within your virtual enterprise. If you do not, download vMA appliance from vmware and deploy it as OVF template.
To enable SSH on the host, login with vSphere client, browse to the Configuration tab and then Security Profile and then click on Properties, highlight SSH and click on Options.
To backup the configuration of the host use the vicfg-cfgbackup command. Here is an example, be sure to use the --server parameter to specify the host that you want to backup:
vicfg-cfgbackup --server <host-ip-address/name> -s <backup-file-name.txt>
vi-admin@localhost:~> vicfg-cfgbackup --server 10.10.10.246 -s 10.10.10.246-backup.txt
Enter username: root
Saving firmware configuration to 10.10.10.246-backup.txt ...
It saves the file on the vMA appliance, you can probably do some scripting to dump all that on a storage device but that is out of scope of this tutorial.
Now lets restore the configuration on same host with the restore option. Here is the command:
vicfg-cfgbackup --server <host-ip-address/name> -l <backup-file-name.txt>
vi-admin@localhost:~> vicfg-cfgbackup --server 10.10.10.246 -l 10.10.10.246-backup.txt
Enter username: root
The restore operation will reboot the host.
Type 'yes' to continue:
Uploading config bundle to configBundle.tgz ...
Performing restore ...
Your host will be in maintenance mode and will reboot with configuration restored. In some situations you may have to use the -f (force) option with the command to force restoration of the configuration. If you want to reset the configuration to factory-default, you can use the -r (reset) option with the command). For further help on vicfg-cfgbackup command, use the --help parameter.
This is just one of the ways to keep a backup and restore of your ESXi hosts, you can also use host profiles to update and restore configuration on multiple hosts at a time and in future tutorials, we will cover using host profiles.
I hope this how-to helps you in your environment. Please remember to test the command in your lab before using it in your production environment. If you run into issues, be sure to post in our forums. Virtualization.net is not responsible for your mistakes.