對於Vmware產品接觸仍是至關少的,由於公司的主要使用的是Microsoft產品,近期公司上線的OA系統就要建立在Vmware Vsphere主機上,因此公司採購了一臺HP 最新的4U(580G9)服務器做爲運行ESXI主機的物理設備,固然配置也不會過低,內存:256GB,磁盤:本地2塊300G磁盤,用於安裝系統,配置Raid1,而後掛載存儲鏈路1T磁盤空間,全部虛擬機都安裝在獨立磁盤中--存儲。主要的問題是僅僅這一臺Vsphere Host,因此對於平常的備份至關重要。網上不少帖子說,若是ESXI系統崩潰了,通常都是重裝(30分鐘),可是重裝後,系統不少配置就沒了,因此在維護過程當中,咱們建議是備份一下ESXI主機的配置文件,這樣重裝後,而後把備份的配置文件導入後咱們會少不少工做量的。因此下面咱們就介紹一下如何備份ESXI主機的配置文件及還原。html
咱們這次使用powercli進行ESXI主機的備份及還原。首先是須要下載powercli工具;首先須要經過vmware註冊的帳戶登陸,而後單點下載---搜索powercli 進行相關版本下載shell
https://my.vmware.com/group/vmware/details?downloadGroup=PCLI630R1_OSS&productId=491windows
https://my.vmware.com/group/vmware/details?downloadGroup=PCLI630R1&productId=491服務器
下載後,咱們準備安裝在windows server2012r2上ide
開始安裝工具
所需組件安裝ui
開始安裝this
安裝完成3d
安裝後會有兩個組件,一個是x86,一個是64位的,因此咱們通常運行x64位的
運行成功
注:若是運行powercli提示錯誤,咱們須要修改powercli的策略,相似windows powershell的命令同樣
使用get-executionpolicy查看狀態確實爲Restricted
使用set-executionpolicy將屬性從Restricted更改成remotesigned
咱們參考官方文檔,使用vsphere Powercli備份esxi主機的配置文件
Using the vSphere PowerCLI 備份
To back up the configuration data for an ESXi host using the vSphere PowerCLI, run this command:
Get-VMHostFirmware -VMHost ESXi_host_IP_address -BackupConfiguration -DestinationPath output_directory
Where ESXi_host_IP_address is the IP address of the ESXi host and output_directory is the name of the directory where the output file will be created.
For example:
Get-VMHostFirmware -VMHost 10.0.0.1 -BackupConfiguration -DestinationPath C:\Downloads
Note: A backup file is saved in the directory specified with the -DestinationPath option.
由於我當前只有一臺ESXI主機,192.168.5.188;在導出配置前,咱們須要鏈接到ESXI主機;
若是不會使用命令的話,咱們能夠先使用命令打開幫助文檔
get-powerCLIHelp connect-viserver
例子:Connect-VIServer ESXIHOST_IP -User 'root' -Password 'password'
因此咱們使用
Connect-VIServer 192.168.5.188 -User 'root' -Password 'password'
接下來咱們能夠判斷是否鏈接成功,可使用get-vm查看當前主機下的因此vm
成功鏈接到ESXI主機後,接下來咱們就是導出ESXI主機配置文件
咱們參考官方文檔,使用vsphere Powercli備份esxi主機的配置文件
Using the vSphere PowerCLI 備份
To back up the configuration data for an ESXi host using the vSphere PowerCLI, run this command:
Get-VMHostFirmware -VMHost ESXi_host_IP_address -BackupConfiguration -DestinationPath output_directory
Where ESXi_host_IP_address is the IP address of the ESXi host and output_directory is the name of the directory where the output file will be created.
For example:
Get-VMHostFirmware -VMHost 10.0.0.1 -BackupConfiguration -DestinationPath C:\Downloads
Note: A backup file is saved in the directory specified with the -DestinationPath option.
因此咱們運行
Get-VMHostFirmware -VMHost 192.168.5.188 -BackupConfiguration -DestinationPath d:\ESXIConfigurationBak
導出成功
若是要還原的話,仍是同樣的方式,先鏈接,而後再還原;
Using the vSphere PowerCLI 還原
Note: When restoring configuration data, the build number of the host must match the build number of the host that created the backup file. Use the -force option to override this requirement.
Put the host into maintenance mode by running the command:
Where ESXi_host_IP_address is the IP address of the ESXi host.
Set-VMHost -VMHost ESXi_host_IP_address -State 'Maintenance'
Restore the configuration from the backup bundle by running the command:
Where ESXi_host_IP_address is the IP address of the ESXi host, backup_file is the name of the backup bundle to use for the restore, andusername and password are the credentials to use when authenticating with the host.
For example:
Set-VMHostFirmware -VMHost 10.0.0.1 -Restore -SourcePath c:\bundleToRestore.tgz -HostUser root -HostPassword exampleRootPassword
Set-VMHostFirmware -VMHost ESXi_host_IP_address -Restore -SourcePath backup_file -HostUser username -HostPassword password
Additional Information
Note: The information about virtual machines is not stored in the config backup and the virtual machines must be re-inventoried from the datastore browser after a config backup restore. Also, bootbank information is not stored in a config backup. If needed, this must be backed up and downloaded separately in a compressed tar file.
For more information, see:
Backing Up Configuration Information with vicfg-cfgbackup section in the vSphere 5.1 Command Line Documentation
Get-VMHostFirmware section in the vSphere PowerCLI Reference
Set-VMHostFirmware section in the vSphere PowerCLI Reference
Note: if you have installed a version of vSphere later than 5.1, see the Command Line Document and PowerCLI Reference for that version in the VMware Documentation Library.
PowerCLI Notes:
Remember that the 64 bit version of PowerCLI is installed in C:\Program Files, and the 32 bit version is in C:\Program Files (x86).
You must always run PowerCLI as Administrator.