{"id":178,"date":"2018-03-14T02:12:23","date_gmt":"2018-03-14T02:12:23","guid":{"rendered":"http:\/\/192.168.50.22\/index.php\/2018\/03\/14\/veeam-free-backup-schedule-script\/"},"modified":"2026-03-15T21:39:35","modified_gmt":"2026-03-16T01:39:35","slug":"veeam-free-backup-schedule-script","status":"publish","type":"post","link":"https:\/\/smegnl.medina.oh.us\/?p=178","title":{"rendered":"Veeam Free Backup Schedule Script"},"content":{"rendered":"<h1>Bellow is a script to get Free Veeam Backup and replication to schedule a VeamZip backup.<\/h1>\n<h6># Author: Vladimir Eremin<br \/>\n# Created Date: 3\/24\/2015<br \/>\n# http:\/\/forums.veeam.com\/member31097.html<br \/>\n#Edited by Roger Saffle 3\/13\/2018 to update some variables problems and mail sending<\/h6>\n<h6>##################################################################<br \/>\n# User Defined Variables<br \/>\n##################################################################<\/h6>\n<h6># Names of VMs to backup separated by comma (Mandatory). For instance, $VMNames = \u201cVM1\u201d,\u201dVM2\u201d<br \/>\n$VMNames = &#8220;<em>VM_GUEST_TO_BACKUP<\/em>&#8220;<\/h6>\n<h6># Name of vCenter or standalone host VMs to backup reside on (Mandatory)<br \/>\n# THIS NEED TO BE THE NAME ON THE VEEAM MACHINE NOT THE NAME IN HYPERV MANAGER<br \/>\n$HostName = &#8220;VM_HOST&#8221;<\/h6>\n<h6># Directory that VM backups should go to (Mandatory; for instance, C:\\Backup)<br \/>\n$Directory = &#8220;C:\\Backup&#8221;<\/h6>\n<h6># Desired compression level (Optional; Possible values: 0 &#8211; None, 4 &#8211; Dedupe-friendly, 5 &#8211; Optimal, 6 &#8211; High, 9 &#8211; Extreme)<br \/>\n$CompressionLevel = &#8220;5&#8221;<\/h6>\n<h6># Quiesce VM when taking snapshot (Optional; VMware Tools are required; Possible values: $True\/$False)<br \/>\n$EnableQuiescence = $True<\/h6>\n<h6># Protect resulting backup with encryption key (Optional; $True\/$False)<br \/>\n$EnableEncryption = $False<\/h6>\n<h6># Encryption Key (Optional; path to a secure string)<br \/>\n$EncryptionKey = &#8220;&#8221;<\/h6>\n<h6># Retention settings (Optional; By default, VeeamZIP files are not removed and kept in the specified location for an indefinite period of time.<br \/>\n# Possible values: Never , Tonight, TomorrowNight, In3days, In1Week, In2Weeks, In1Month)<br \/>\n$Retention = &#8220;Never&#8221;<\/h6>\n<h6>##################################################################<br \/>\n# Notification Settings<br \/>\n##################################################################<\/h6>\n<h6># Enable notification (Optional)<br \/>\n$EnableNotification = $True<\/h6>\n<h6># Email SMTP server<br \/>\n$SMTPServer = &#8220;SMPT.SERVER&#8221;<\/h6>\n<h6># Email FROM<br \/>\n$EmailFrom = &#8220;Veeam_BU@domain.com&#8221;<\/h6>\n<p># Email TO<br \/>\n$EmailTo = &#8220;admin@domain.com&#8221;,&#8221;admin2@domain.com&#8221;<\/p>\n<h6># Email subject<br \/>\n$EmailSubject = &#8220;Subject&#8221;<\/h6>\n<h6>##################################################################<br \/>\n# Email formatting<br \/>\n##################################################################<\/h6>\n<h6>$style = &#8220;&lt;style&gt;BODY{font-family: Arial; font-size: 10pt;}&#8221;<br \/>\n$style = $style + &#8220;TABLE{border: 1px solid black; border-collapse: collapse;}&#8221;<br \/>\n$style = $style + &#8220;TH{border: 1px solid black; background: #dddddd; padding: 5px; }&#8221;<br \/>\n$style = $style + &#8220;TD{border: 1px solid black; padding: 5px; }&#8221;<br \/>\n$style = $style + &#8220;&lt;\/style&gt;&#8221;<\/h6>\n<h6>##################################################################<br \/>\n# End User Defined Variables<br \/>\n##################################################################<\/h6>\n<h6>#################### DO NOT MODIFY PAST THIS LINE ################<br \/>\nAsnp VeeamPSSnapin<\/h6>\n<h6>$Server = Get-VBRServer -name $HostName<br \/>\n$MesssagyBody = @()<\/h6>\n<h6>#&nbsp;<span style=\"color: #ff0000;\">CHANGE $VM= VALUE BELLOW Find-VBRHvEntity FOR HYPERV OR Find-VBRViEntity FOR VMWARE<\/span><\/h6>\n<h6>foreach ($VMName in $VMNames)<br \/>\n{<br \/>\n$VM = Find-<span style=\"color: #ffff00;\">VBRHvEntity<\/span> -Name $VMName -Server $Server<\/p>\n<p>If ($EnableEncryption)<br \/>\n{<br \/>\n$EncryptionKey = Add-VBREncryptionKey -Password (cat $EncryptionKey | ConvertTo-SecureString)<br \/>\n$ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention -EncryptionKey $EncryptionKey<br \/>\n}<\/p>\n<p>Else<br \/>\n{<br \/>\n$ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention<br \/>\n}<\/p>\n<p>If ($EnableNotification)<br \/>\n{<br \/>\n$TaskSessions = $ZIPSession.GetTaskSessions().logger.getlog().updatedrecords<br \/>\n$FailedSessions = $TaskSessions | where {$_.status -eq &#8220;EWarning&#8221; -or $_.Status -eq &#8220;EFailed&#8221;}<\/p>\n<p>if ($FailedSessions -ne $Null)<br \/>\n{<br \/>\n$MesssagyBody = ($ZIPSession | Select-Object @{n=&#8221;Name&#8221;;e={($_.name).Substring(0, $_.name.LastIndexOf(&#8220;(&#8220;))}} ,@{n=&#8221;Start Time&#8221;;e={$_.CreationTime}},@{n=&#8221;End Time&#8221;;e={$_.EndTime}},Result,@{n=&#8221;Details&#8221;;e={$FailedSessions.Title}})<br \/>\n}<\/p>\n<p>Else<br \/>\n{<br \/>\n$MesssagyBody = $MesssagyBody + ($ZIPSession | Select-Object @{n=&#8221;Name&#8221;;e={($_.name).Substring(0, $_.name.LastIndexOf(&#8220;(&#8220;))}} ,@{n=&#8221;Start Time&#8221;;e={$_.CreationTime}},@{n=&#8221;End Time&#8221;;e={$_.EndTime}},Result,@{n=&#8221;Details&#8221;;e={($TaskSessions | sort creationtime -Descending | select -first 1).Title}})<br \/>\n}<\/p>\n<p>}<br \/>\n}<br \/>\nIf ($EnableNotification)<br \/>\n{<br \/>\n$body = $MesssagyBody | Out-String<br \/>\nSend-MailMessage -from $EmailFrom -To $EmailTo&nbsp; -Subject $EmailSubject -smtpServer $SMTPServer -Body $Body<\/h6>\n<h6>}<\/h6>\n<h6>&nbsp;<\/h6>\n","protected":false},"excerpt":{"rendered":"<p>Bellow is a script to get Free Veeam Backup and replication to schedule a VeamZip backup. # Author: Vladimir Eremin # Created Date: 3\/24\/2015 # http:\/\/forums.veeam.com\/member31097.html #Edited by Roger Saffle 3\/13\/2018 to update some variables problems and mail sending ################################################################## # User Defined Variables ################################################################## # Names of VMs to backup separated by comma (Mandatory). [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3014,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-178","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-figured-it-out"],"_links":{"self":[{"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=\/wp\/v2\/posts\/178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=178"}],"version-history":[{"count":0,"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=\/wp\/v2\/posts\/178\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=\/wp\/v2\/media\/3014"}],"wp:attachment":[{"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smegnl.medina.oh.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}