Esxi主机配置文件备份及还原介绍

简介:

对于Vmware产品接触还是相当少的,因为公司的主要使用的是Microsoft产品,近期公司上线的OA系统就要创建在Vmware Vsphere主机上,所以公司采购了一台HP 最新的4U(580G9)服务器作为运行ESXI主机的物理设备,当然配置也不会太低,内存:256GB,磁盘:本地2块300G磁盘,用于安装系统,配置Raid1,然后挂载存储链路1T磁盘空间,所有虚拟机都安装在独立磁盘中--存储。主要的问题是仅仅这一台Vsphere Host,所以对于日常的备份相当重要。网上很多帖子说,如果ESXI系统崩溃了,一般都是重装(30分钟),但是重装后,系统很多配置就没了,所以在维护过程中,我们建议是备份一下ESXI主机的配置文件,这样重装后,然后把备份的配置文件导入后我们会少很多工作量的。所以下面我们就介绍一下如何备份ESXI主机的配置文件及还原。

wKioL1e1d_7DjBw8AAERjHKFz88917.png-wh_50

我们此次使用powercli进行ESXI主机的备份及还原。首先是需要下载powercli工具;首先需要通过vmware注册的账户登录,然后单点下载---搜索powercli 进行相关版本下载

https://my.vmware.com/group/vmware/details?downloadGroup=PCLI630R1_OSS&productId=491

image

image

https://my.vmware.com/group/vmware/searchresults?client=my_download&site=my_download&proxystylesheet=my_download_en&gsa_lang=en&c=ALL&q=powercli+6.0

https://my.vmware.com/group/vmware/details?downloadGroup=PCLI630R1&productId=491

image

下载后,我们准备安装在windows server2012r2上

image

image

image

开始安装

image

image

image

所需组件安装

image

开始安装

image

安装完成

image

安装后会有两个组件,一个是x86,一个是64位的,所以我们一般运行x64位的

image

运行成功

image

https://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=2042141&sliceId=1&docTypeID=DT_KB_1_1&dialogID=197519853&stateId=0%200%20197549962

注:如果运行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:

1
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:

1
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主机;

如果不会使用命令的话,我们可以先使用命令打开帮助文档

1
get-powerCLIHelp connect-viserver

image

image

例子:Connect-VIServer ESXIHOST_IP -User 'root' -Password 'password'

所以我们使用

1
Connect-VIServer 192.168.5.188 -User  'root'  -Password  'password'

image

image

接下来我们可以判断是否连接成功,可以使用get-vm查看当前主机下的所以vm

image

成功连接到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:

1
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:

1
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.

所以我们运行

1
Get-VMHostFirmware -VMHost 192.168.5.188 -BackupConfiguration -DestinationPath d:\ESXIConfigurationBak

image

导出成功

image

如果要还原的话,还是一样的方式,先连接,然后再还原;

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.

  1. Put the host into maintenance mode by running the command:     
         
    Where ESXi_host_IP_address is the IP address of the ESXi host.

  2. 1
    Set-VMHost -VMHost ESXi_host_IP_address -State  'Maintenance'
  3. 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

  4. 1
    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:

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.


本文转自 高文龙 51CTO博客,原文链接:http://blog.51cto.com/gaowenlong/1840042,如需转载请自行联系原作者
相关文章
|
4月前
|
数据挖掘 数据库 虚拟化
服务器数据恢复—XenServer虚拟机磁盘文件丢失的数据恢复案例
服务器数据恢复环境: 某品牌720服务器搭配该品牌某型号RAID卡,使用4块STAT硬盘组建了一组RAID10阵列。服务器上部署XenServer虚拟化平台,系统盘 +数据盘两个虚拟机磁盘。虚拟机上安装的是Windows Server操作系统,作为Web服务器使用,网站使用的是SQLServer数据库。 服务器故障: 服务器意外断电导致XenServer中一台VPS(XenServer虚拟机)不可用,虚拟磁盘文件丢失。
服务器数据恢复—XenServer虚拟机磁盘文件丢失的数据恢复案例

相关实验场景

更多