Saturday 29 June 2013

ESXi Backup using vicfg-cfgbackup command

Vicfg-cfgbackup is a command line utility to take a backup of the ESXi server. It can be very helpful if you have a scenario, where your ESXi has crashed and you want to restore your ESXi instantly.

First step:
a)      Lets take a backup of the esxi configuration, I am doing this using vMA.   Connect to your vMA appliance using ssh and set your Esxi as the deafult target
#vifp addserver (Esxi server name) –username (root) –password (password)
#vifp listservers ( to see the Esxi server has been added)        
                         
                                   Figure 1: Adding your esxi to vMA appliance.


b)      Set the esxi as the default target in vMA to run the backup command. 
# vifptarget –set (your esxi server name)
     
                            Figure 2: Setting the ESXi as target server.


c)       Run the command to backup the Esxi configuration. Using the below command, I am able to save the backup file on the vMA inside the /tmp/backup location.
# vicfg-cfgbackup -s /tmp/backup/esxi3-vcloud_dd_ww.cfg
                                Figure 3: Creating a backup of the ESXi server.
Note: I realized that by creating a folder inside /tmp folder, the backup file was not getting created. I had to change the permissions to r/w for the child folder as well. Normally, I use the chmod 777 by default to give all sorts of r/w permissions.


d)      I have taken a screenshot of the Esxi networking and some advanced parameters to make sure that the settings are restored after we restore the backup.
                                Figure 4: Networking view on the ESXi server .

                         Figure 5: Syslog settings on the ESXi server.


e)      Next Let’s reinstall the Esxi server, formatting the existing filesystem and assign a new IP address to the esxi server. Let’s add the reformatted Esxi to the vCenter and check if any old configuration exists. As you can see from the below screenshots , that the previous configurations does not exist anymore.
                                Figure 6: Networking view on the ESXi server after reinstallation.

                                Figure 7: Syslog setting on the ESXi after reinstallation.


f)      Lets add this esxi to the vMA vappliance and  reload the backup config.
# vifp addserver (new esxi ip )  --authpolicy fpauth –username root –password (password)
To reload the configuration file on the new Esxi server:
# vicfg-cfgbackup –l /tmp/backup/(backup file name)
(Note - -l reloads the backup configuration file )
                                Figure 8: Adding the reinstalled ESXi to vMA and reloading the  
                                       configuration file.


g)      Your ESXi should now restart and after some time you can see that the first ESXi instance has come back in your vCenter and the 2nd instance has gone into not responding state. Let’s also check the Networking and other configuration details.

                                Figure 9 : Verify that the ESXi network configuration has been restore.

                                Figure 10: Verify that the Syslog setting has been restored.

So, as you can see that the Esxi server has been completely restore using the backup from vicfg-cfgbackup command.
If you want to get rid of the ESXi entry in your vMA appliance you can use the below command.
# vifp removeserver 192.168.0.151 --force.
xx

No comments: