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