对于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.