Veeam對於備份虛擬機而言,挺不錯的,並且還有免費版,目前最新的是Veeam Backup Free Edition 9.5。面試
所以,免費版天天的備分量是很大的,有條件的能夠考慮使用收費版。
言歸正傳,咱們如今來設置一下,讓免費版也有計劃任務。
免費版在程序界面是設置不了計劃的,誰讓它是免費的呢,可是咱們能夠藉助PowerShell和PS腳本,手動來作個包含批量備份的計劃任務。 shell
# VM names separated by commas $VMNames = "Windows Server 1","Windows Server 2","CentOS 7" # vCenter name/IP $HostName = "192.168.0.1" # Directory that VM backups should go to $Directory = "D:\Backup" # Desired compression level, following compression level from Veeam (Optional) $CompressionLevel = "9" # Quiesce VM when taking snapshot (Optional; VMware Tools are required; Possible values: $True/$False) $EnableQuiescence = $True # Protect resulting backup with encryption key (Optional; $True/$False) $EnableEncryption = $False # Encryption Key (Optional; path to a secure string, C:\SecureString.txt" $EncryptionKey = "" # Retention settings (Optional; By default, VeeamZIP files are not removed and kept in the specified location for an indefinite period of time. # Possible values: Never , Tonight, TomorrowNight, In3days, In1Week, In2Weeks, In1Month) $Retention = "In1Week" # Email Settings # Enable notification (Optional) $EnableNotification = $True # Email SMTP server $SMTPServer = "smtp.smtp.com" # Email FROM $EmailFrom = "sender@mail.com" # Email TO $EmailTo = "recipient@mail.com" # Email subject $EmailSubject = "Veeam Backup Job" # Email formatting $style = "<style>BODY{font-family: Arial; font-size: 10pt;}" $style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}" $style = $style + "TH{border: 1px solid black; background: #54b948; padding: 5px; }" $style = $style + "TD{border: 1px solid black; padding: 5px; }" $style = $style + "</style>" ################################################################## # End User Defined Variables ################################################################## #################### DO NOT MODIFY PAST THIS LINE ################ Asnp VeeamPSSnapin $Server = Get-VBRServer -name $HostName $mbody = @() foreach ($VMName in $VMNames) { $VM = Find-VBRViEntity -Name $VMName -Server $Server $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention If ($EnableNotification) { $TaskSessions = $ZIPSession.GetTaskSessions() $FailedSessions = $TaskSessions | where {$_.status -eq "EWarning" -or $_.Status -eq "EFailed"} if ($FailedSessions -ne $Null) { $mbody = $mbody + ($ZIPSession | Select-Object @{n="Name";e={($_.name).Substring(0, $_.name.LastIndexOf("("))}} ,@{n="Start Time";e={$_.CreationTime}},@{n="End Time";e={$_.EndTime}},Result,@{n="Details";e={$FailedSessions.Title}}) } Else { $mbody = $mbody + ($ZIPSession | Select-Object @{n="Name";e={($_.name).Substring(0, $_.name.LastIndexOf("("))}} ,@{n="Start Time";e={$_.CreationTime}},@{n="End Time";e={$_.EndTime}},Result,@{n="Details";e={($TaskSessions | sort creationtime -Descending | select -first 1).Title}}) } } } If ($EnableNotification) { $Message = New-Object System.Net.Mail.MailMessage $EmailFrom, $EmailTo $Message.Subject = $EmailSubject $Message.IsBodyHTML = $True $message.Body = $mbody | ConvertTo-Html -head $style | Out-String #$SMTP = New-Object Net.Mail.SmtpClient($SMTPServer) #$SMTP.Send($Message) }
VMNames:後面跟虛擬機的名字,在vCenter、ESXi上顯示的名字
HostName:vCenter服務器的IP或域名,我只在vCenter上面試過,由於涉及到多臺服務器。若是沒有vCenter而且要備份多臺服務器裏的虛擬機,不清楚能不能像vmnames這樣作一個foreach。
Directory:目錄,支持網絡路徑,即\192.168.x.x\Folder
CompressionLevel :0 - None, 4 - Dedupe-friendly, 5 - Optimal, 6 - High, 9 - Extreme。我是用的9,默認是5。
Retention:這個沒有測過,備份保存天數。In1Week是保存一週。不清楚會不會自動刪除舊備份。若是不會刪,看我以前的一個帖子,手動寫個清理腳本也能夠。
EMAIL那部分就是SMTP地址、發件人、收件人,最後兩行我註釋掉了,若是須要發送郵件,去掉最後兩行的註釋就能夠。 api
而後保存這個腳本,能夠放到C盤,起名VeeamZip.ps1
PowerShell路徑:C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
計劃任務裏,設置powershell的路徑,參數設置"C:\VeeamZip.ps1" 服務器
OK,設置個任務它就能夠自動備份了,添加完後能夠手動執行一下看看效果。 網絡
以上腳本參考外國網站,具體哪一個網站我沒記,搜索一下應該能夠搜索到原文的。ide