Backup/Restore ESXi config

SOURCE: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2042141

It’s important to rerun backup every time you update patches, otherwise you can’t restore the configuration

WINDOWS METHOD
-Download and install vSphere SDK for Perl from
-click Run Search PowerShell
-right click Windows PowerShell/Run as Administrator
PS C:\WINDOWS\system32> Set-ExecutionPolicy remotesigned
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is “Y”):
Download PowerCLI from http://vmware.com/go/PowerCLI
right click VMware-PowerCLI-5.8.0-2057893.exe/Run as Administrator and install
-click Run Search PowerShell
-right click Windows PowerShell/Run as Administrator
PS C:\WINDOWS\system32> Set-ExecutionPolicy remotesigned
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is “Y”):
PS>cd  C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts

PS>.\Initialize-PowerCLIEnvironment.ps1

LINUX METHOD
Download and install vMA from
BACKUP:
Method1 PowerCLI
PS> Connect-VIServer 10.0.0.200 -user root -password secret
PS> Get-VMHost | Get-VMHostFirmware -BackupConfiguration -DestinationPath c:\download
Host            Data
—-            —-
10.0.0.200      c:\download\configBundle-10.0.0.200.tgz

Method2 ESXi CLI

To synchronize the configuration changed with persistent storage, run the command:
#vim-cmd hostsvc/firmware/sync_config
To backup the configuration data for an ESXi host, run the command:
#vim-cmd hostsvc/firmware/backup_config

Note: The command should output a URL in which a web browser may be used to download the file. The backup file is located in the /scratch/downloads directory as configBundle-<HostFQDN>.tgz

Method3 vSphere CLI

open menu Start/Programs/VMware/VMware vSphere CLI/Command Prompt

>vicfg-cfgbackup.pl –server=10.0.0.200 –username=root –password=secret -s c:\Download\ESXi_backup.txt

Method4 vMA

#vicfg-cfgbackup –server 10.0.0.200 –username=root –password=secret -s /root/ESXi010115.txt

RESTORE:

Method1 PowerCLI
PS> Connect-VIServer 10.0.0.200 -user root -password secret
-power off all vms
PS> Set-VMHost -VMHost 10.0.0.200 -State Maintenance

Name                 ConnectionState PowerState NumCpu CpuUsageMhz CpuTotalMhz   MemoryUsageGB   MemoryTotalGB Version
—-                 ————— ———- —— ———– ———–   ————-   ————- ——-
10.0.0.200           Maintenance     PoweredOn       8         416       18392           6.330          95.938   5.5.0

PS> Set-VMHostFirmware -VMHost 10.0.0.200 -Restore -SourcePath c:\download\configBundle-10.0.0.200.tgz -HostUser root -HostPassword secret

Method2 ESX CLI

Put the host into maintenance mode by running the command:
>vim-cmd hostsvc/maintenance_mode_enter
Copy the backup configuration file to a location accessible by the host and run the command:
In this case, the configuration file was copied to the host’s /tmp directory. For more information, see Using SCP tocopy files to or from an ESX host (1918).
>vim-cmd hostsvc/firmware/restore_config /tmp/configBundle.tgz

Note: Executing this command will initiate an automatic reboot of the host after command completion.

Method3 vSphere CLI

C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>perl.exe vicfg-hostops.pl –server 10.0.0.200 –username root –password secret -o enter

Host esx0.poc.com entered into maintenance mode successfully.

C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>perl.exe vicfg-cfgbackup.pl –server 10.0.0.200 –username root –password secret -f -l c:\Download\ESXi_backup.txt

C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>perl.exe vicfg-hostops.pl –server 10.0.0.200 –username root –password secret -o exit

Method4 vMA

NOTE: vMA must not under ESXi that going to be Maintenance
#vicfg-hostops –server 10.0.0.200 –username=root –password=secret -o enter
#vicfg-cfgbackup –server 10.0.0.200 –username=root –password=secret -f -l /root/ESXi010115.txt
#vicfg-hostops –server 10.0.0.200 –username=root –password=secret -o exit
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s