windows 安裝 PowerCLI 可以的
把之前做的拿來你自己改看看
eip-snap.bat
#echo off
Title,Report Script &color 9e
for /f "usebackq delims=$" %%a in (`cd`) do (
set SCRIPTDIR=%%a
)
(Set ScriptFile=C:\script\EIP_SNAP.ps1 )
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\"";%ScriptFile%"
EIP_SNAP.ps1
# snap VM
# [ON LINE] EIP
# Eat Params
$doVMname = '`[ON LINE`] EIP'
$vCenterName = "192.168.0.200"
$filenameFormat = "EIP" + (get-date -Format "yyyy-MM-dd")
$delfilenameFormat = "EIP" + (get-date (get-date).addDays(-3) -Format "yyyy-MM-dd")
# Load Powershell snapin from VMware
# ignore all errors
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
# Connect ESX/vCenter Server
connect-viserver $vCenterName
$VMF = Get-VM $doVMname
# juet test get snapshot list for $doVMname
get-snapshot -vm $VMF
# take snapshoot
New-snapshot -VM $VMF -name $filenameFormat -Quiesce -Memory
# del old snapshoot
get-snapshot -VM $VMF -name $delfilenameFormat | remove-snapshot -confirm:$false
eip-snap.bat 放到排程 ...設成不登入與否都要執行
ESXI 一般是FREE版單機用ghettoVCB排程執行備份(參數可設定保留幾份)
架了vcenter通常會架上HA的功能,備份也都改用付費備份機制