{"id":23,"date":"2008-08-03T00:15:09","date_gmt":"2008-08-02T23:15:09","guid":{"rendered":"http:\/\/simoncpage.co.uk\/blog\/?p=23"},"modified":"2008-10-19T15:14:51","modified_gmt":"2008-10-19T14:14:51","slug":"exchange-2007-backup-utility-reporting-script","status":"publish","type":"post","link":"https:\/\/simoncpage.co.uk\/blog\/2008\/08\/exchange-2007-backup-utility-reporting-script\/","title":{"rendered":"Exchange 2007 | windows backup utility &#038; email reporting vb script"},"content":{"rendered":"<p>For regular backups of our Exchange 2007 email database server and to clear the all important log files we use the standard Backup Utility which is bundled with Windows 2003 Server. It does its job well except, unless you log on to the machine, you can&#8217;t tell if a backup failed or if it was sucessful &#8211; as there is no native reporting.<\/p>\n<p>The options you have are either to use a commercial third party backup application which includes reporting or create yourself a scheduled VB script to email you the backup logs. The later is exactly what I did.<\/p>\n<p>Below is my VB script that is run every morning from the exchange server. It sends an email to the IT distribution group with the latest backup log file in the body and as a text file attachment (the reason for the text file is a convenient way of storing as each text file is timestamped in the script).<\/p>\n<blockquote><p>Option Explicit<\/p>\n<p>&#8216; ***********************************************************<br \/>\n&#8216; * Red Chilli exchange backup email reporting<br \/>\n&#8216; * by Simon Page<br \/>\n&#8216; ***********************************************************<\/p>\n<p>&#8216; Dim variables<br \/>\nDim oFSO, oWshNetwork, oCDO, oFolder, oFiles, oFile<br \/>\nDim filesys, filesys2, objFile, objFile2, objTextStream, copyBody<br \/>\nDim strFileName, strComputerName<\/p>\n<p>&#8216; Create Objects<br \/>\nSet oFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br \/>\nSet oWshNetwork = WScript.CreateObject(&#8220;WScript.Network&#8221;)<br \/>\nset filesys = CreateObject (&#8220;Scripting.FileSystemObject&#8221;)<br \/>\nset filesys2 = CreateObject (&#8220;Scripting.FileSystemObject&#8221;)<\/p>\n<p>&#8216; Copy file<br \/>\nset objFile = filesys.GetFile(&#8220;c:\\WINDOWS\\Tasks\\SchedLgu.Txt&#8221;)<br \/>\nobjFile.Copy(&#8220;c:\\Logs\\SchedLgU-&#8221; &amp; Replace(CStr(Date()), &#8220;\/&#8221;, &#8220;-&#8220;) &amp; &#8220;.Txt&#8221;)<\/p>\n<p>&#8216; Open copied file for reading<br \/>\nset objFile2 = filesys2.GetFile(&#8220;c:\\Logs\\SchedLgU-&#8221; &amp; Replace(CStr(Date()), &#8220;\/&#8221;, &#8220;-&#8220;) &amp; &#8220;.Txt&#8221;)<br \/>\nset objTextStream = objFile2.OpenAsTextStream(1,True)<\/p>\n<p>copyBody = objTextStream.ReadAll<\/p>\n<p>&#8216; Set constants<br \/>\nConst BACKUP_LOG_PATH = &#8220;C:\\Logs&#8221;<br \/>\nConst EMAIL_RECIPIENT = &#8220;email@domain.com&#8221;<\/p>\n<p>&#8216; Set variable defaults<br \/>\nstrFileName = &#8220;SchedLgU-&#8221; &amp; Replace(CStr(Date()), &#8220;\/&#8221;, &#8220;-&#8220;) &amp; &#8220;.Txt&#8221;<br \/>\nstrComputerName = oWshNetwork.ComputerName<\/p>\n<p>&#8216;If strFileName &lt;&gt; &#8220;&#8221; Then<\/p>\n<p>EmailLog(strFileName)<\/p>\n<p>&#8216;End If<\/p>\n<p>Sub EmailLog(logFilePath)<\/p>\n<p>Set oCDO = CreateObject(&#8220;CDO.Message&#8221;)<\/p>\n<p>oCDO.Subject = &#8220;EXCHANGE BACKUP FULL LOG &#8211; &#8221; &amp; strComputerName &amp; &#8221; &#8211; &#8221; &amp; CStr(Date())<br \/>\noCDO.From = &#8220;email@domain.com&#8221;<br \/>\noCDO.To = EMAIL_RECIPIENT<\/p>\n<p>oCDO.TextBody = copyBody<\/p>\n<p>oCDO.AddAttachment BACKUP_LOG_PATH &amp; &#8220;\\&#8221; &amp; logFilePath<\/p>\n<p>oCDO.Configuration.Fields.Item _<br \/>\n(&#8220;<a href=\"http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpauthenticate\">http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpauthenticate<\/a>&#8220;) = _<br \/>\n1<\/p>\n<p>oCDO.Configuration.Fields.Item _<br \/>\n(&#8220;<a href=\"http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendusername\">http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendusername<\/a>&#8220;) = _<br \/>\n&#8220;USERNAME&#8221;<\/p>\n<p>oCDO.Configuration.Fields.Item _<br \/>\n(&#8220;<a href=\"http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendpassword\">http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendpassword<\/a>&#8220;) = _<br \/>\n&#8220;PASSWORD&#8221;<\/p>\n<p>oCDO.Configuration.Fields.Item _<br \/>\n(&#8220;<a href=\"http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendusing\">http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendusing<\/a>&#8220;) = 1<\/p>\n<p>oCDO.Configuration.Fields.Item _<br \/>\n(&#8220;<a href=\"http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpserver\">http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpserver<\/a>&#8220;) = _<br \/>\n&#8220;SMTP SERVER&#8221;<\/p>\n<p>oCDO.Configuration.Fields.Item _<br \/>\n(&#8220;<a href=\"http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpserverport\">http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpserverport<\/a>&#8220;) = _<br \/>\n25<\/p>\n<p>oCDO.Configuration.Fields.Update<\/p>\n<p>oCDO.Send<\/p>\n<p>set oCDO = Nothing<\/p>\n<p>End Sub<\/p>\n<p>objTextStream.Close<br \/>\nset filesys = Nothing<br \/>\nset filesys2 = Nothing<br \/>\nSet oFSO = Nothing<br \/>\nSet oWshNetwork = Nothing<\/p><\/blockquote>\n<p>Just copy and save the above script as &#8220;filename.vbs&#8221; in an application like notepad and simply schedule this vbs file to run sometime relevant to the backups you are running.<\/p>\n<p>This script can be used on any server or workstation where you have the backup utility running scheduled tasks and you don&#8217;t want to log on to the server to check the the backups all complete without issue.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For regular backups of our Exchange 2007 email database server and to clear the all important log files we use the standard Backup Utility which is bundled with Windows 2003 Server. It does its job well except, unless you log on to the machine, you can&#8217;t tell if a backup failed or if it was [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[12],"tags":[24,21,275,54,161,27,30],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/posts\/23"}],"collection":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":0,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"wp:attachment":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}