[Reprint] VMware PowerCli batch virtual machine snapshot backup

Brief introduction

HTTPS: // yq.aliyun.com/articles/636302 

thanks to information provided by the party of God.

 

PowerCLI Common Command List: 

. 1 , Connect- VIServer - connected virtualization platform
 2 , GET - VMHost - ESXi host displays the list
 . 3 , GET - Cluster - displays a list of clusters
 . 4 , GET - Datastore - displays a list of storage
 . 5 , GET - ResourcePool - Display resource pool
 6 , GET - vm - displays a list of virtual machine
 7 , GET - virtualswitch - displays a list of virtual switch
 8 , start-vm \ STOP- vm - start or shut down the virtual machine
 9 , new new - vm - create a virtual machine
 10 , GET -template - displays the list of templates
 11 , GET - oscustomizationspec - display custom specifications list of
 12 , GET - vapp - show vapp application list
 13 , GET - Folder - displays the folder list
 14 , GET - vicommand - displays list of all commands 

15 , GET - helo- help 
---------------- 
Disclaimer: This article is the original article CSDN bloggers "CIAS", and follow CC 4.0 BY- SA copyright agreement, reproduced, please attach the original source link and this statement. 
Original link: HTTPS: // blog.csdn.net/hanzheng260561728/article/details/76531808

VMware PowerCli batch virtual machine snapshot backup

 
paoge   2018-09-06 15:09:18  Browse 1599
 

In purchasing the server, the general will consider whether to support virtualization, server virtualization mainly related to CPU, and motherboard whether to support virtualization, the best companies in the industry is overtaken by the virtual VMware, the major server supports ESXI system They are generally support virtualization. Benefits of virtualization is a physical machine can be virtualized into a plurality of separate virtual servers, virtual servers are independent, non-interfering. As the author of the company's servers are equipped with ESXI systems, and virtualization management through VMware vSphere, but the problem is encountered: When there is a large number of virtual machines, manual snapshot policy becomes a waste of time, and not friendly. Focus of this paper is to introduce a batch snapshot policy to virtual machines with VMware's tools VMware PowerCli.

 

VMware PowerCli

VMware PowerCLI is in a command-line management tools. General management uses vSphrere Client or VMware vSphere Web Client, vSphere PowerCLI you can manage VMware vSphere or VMware vCenter host through the command line. In analogy to be here, PowerCLI equivalent dos command in the windows below, you can call directly to the underlying VMware's snapshot, etc., with high flexibility and programmability

Traditional snapshot of the virtual machine is performed by manually, as shown below

Pictures .png

When the number of virtual machines is relatively small when the snapshot test by manual approach is relatively straightforward, but more the number of virtual machines (such as the author of the company's virtual machine 60, if all manually operated, will crazy), then how to achieve volume snapshots of virtual machines strategy?

 

 

VMware PowerCli installation

VMware PowerCli installation package I share in Baidu cloud disk ( https://pan.baidu.com/s/1fFm9jh8PJXBuqXJ3wEewTQ  extract password: akux) versions exist, if interested can go to VMware's official website to download, but it looks like Charges. Employed herein is for the installation of VMware-PowerCLI6.5.

Pictures .png

VMware-PowerCLI6.5 installation depends on the version 3.0 or more windows management framework, if the version is less than 3.0 in the installation process an error prompt information. windows management framework 3.0 can be installed on the windows of the official website to download, address: https://www.microsoft.com/en-us/download/details.aspx?id=34595    (here omitted the process windows management framework 3.0 directly next to it, need to restart after installation)

Double-click the installation file to start the installation, it will install the VIX and related plug-ins, as shown below:

Pictures .png

Followed by installation of a PowerCLI

Pictures .png

After installation is complete, create two shortcut on the desktop, a 30 and a 64, as in FIG.

Pictures .png

Startup Configuration VMware PowerCli

As the author is using 64-bit system, so using a shortcut into the 64-bit, double-click to enter:

111.png

 

The reason given is due to the system default script execution policy to Restricted, at this time Powercli not function properly, you need to modify the execution policy RemoteSigned, of which there are two commands are as follows:

get-executionpolicy ### Viewing System script execution policy way 
set-executionpolicy remotesigned ### remotesigned way to modify the test

Pictures .png

Restart the interface you can enter the following window interface

Pictures .png

 

VMware PowerCli achieve volume virtual machine management

power shell login server: connect-viserver 192.168.1.201 -user 'root' -password 'password'

192.168.1.201 IP address of the physical server

-user login username physical server

-password password for the corresponding

After logging interface may look as follows, indicating a successful login server

Pictures .png

(1), view the server all the virtual machines: get-vm

Pictures .png

(2) for all server snapshot, snapshot name is: 20180906:

get-vm | New-Snapshot -Name "20180906-2"

In PowerCli shown below:

Pictures .png

Corresponding to the following information VMware vSphere console:

Pictures .png

Similarly, on the boot of a virtual machine snapshot:

get-vm |where {$_.PowerState -eq "PoweredOn"} |New-Snapshot -Name "20180906"

(3) delete the snapshot of 20,180,906:

get-vm | get-snapshot -name "20180906" | remove-snapshot

 

Can be integrated on a physical server virtual machine for batch snapshot policy by the above command, on the adoption of the timing script execution and timing of the snapshot deletion policy, will be explained in the second part

 

 

 

PS: The official address of VMware powerCli: https://www.vmware.com/support/developer/PowerCLI/index.html

VMware PowerCli official official document: https://docs.microsoft.com/zh-cn/powershell/scripting/getting-started/cookbooks/using-format-commands-to-change-output-view?view=powershell-5.1

 

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12465543.html