The other day I was working on a project where I was migrating HP drives from internal storage, into a P2000 G3 SAS SAN. ( which worked amazingly btw) The catch was that besides being a local datastore they also held the ESXi hypervisor, so when I pulled them out of the server it would no longer boot up. From each server, I was removing 4 x 300GB drives, and in their place, I was installing 2 x 146GB drives (these drives are going to be used simply for ESXi on a RAID1).
So I used Storage vMotion to move all of the VM’s from internal storage to a datastore on the SAN, and then before shutting down the server and removing the drives I used the vSphere Management Assistant (vMA) to backup my ESXi config. This was a pretty simple process:
- I added my server to the list of VI Fast Pass servers (optional* see below)
- Set my host to the one I wanted to work with vifptarget -s esxi1.jpaul.local (optional* see below)
- Then ran vicfg-cfgbackup on the host: vicfg-cfgbackup esxi1.jpaul.local
So now I have the configuration of my ESXi server backed up, so I shutdown the server and removed all of its internal storage. I then put those drives into the P2000 G3 and created a new Vdisk, and then a new Volume and presented it back to the VMware servers. The next step was to install my two new 146GB drives in the server and boot her back up. After powering on the server I inserted the ESXi 4.1 installation CD as well so I could boot off of it and get the install started.
After the installation was completed it asked to reboot like normal, I hit enter and the host rebooted and then came back up and received a DHCP address. I hit F2 and logged in long enough to set the root password on the machine. Remember at this point vCenter has no idea about this host because it has pulled a DHCP address which is different than its statically assigned address, and there is no vCenter agent installed on it anymore.
The next step was to restore the configuration we just backed up onto this vanilla host, so I went back to my vMA shell. All it takes is one command:
After issuing the command it will ask for the username and password of the vanilla installation. The only reason I logged in and set a password is that I didn’t know if it would bomb out with a blank password, so that step may not be needed, but I haven’t tested it. Then it will prompt you to type ‘yes’ to acknowledge that it will reboot the box after the config has been restored, which shouldn’t be a problem since it’s a brand new install.
Also when the server reboots and comes back up you can go into vCenter and right click the server (which will say not responding or disconnected) and right click and select connect. vCenter will reinstall the vCenter agent to the system and join it back into the cluster without any further configuration.
That’s it, ESXi backup in about 5 commands. My future plans are to put these commands into a bash script and include some logic so that I could backup the config’s from my ESXi servers once a day, and keep them dated like “esxi1-2011-03-12.cfg”. Then if one of my USB sticks fail, I have a very easy way to restore the config to a new stick. with minimal manual reconfiguration.
- The first two steps of the backup are not required, instead you could just issue one command to do the backup, however, if you use vMA regularly it is beneficial to add your hosts to fast pass. If you want to not use fast pass, then all you need to do is specify the host on each command like this:
- When I was putting this article together I got the screenshots from my lab gear, and I backed up a config from a 4.1 host and tried to restore it to a 4.1 update 1 host, and it failed. So make sure that if you are doing to use this method that you make a note of the exact build you are running and reload the server with that build before trying to restore.
Here is what the error looked like: