[Box Backup] Which notifyScript is used?
Roy
boxbackup@boxbackup.org
Thu, 20 Nov 2008 00:25:30 +0100
Chris Wilson wrote:
> Hi Roy,
>
> On Thu, 20 Nov 2008, Roy wrote:
>
>
>> I had some troubles with the notify script that was in the latest
>> Windows release. But that bug is solved by Chris now. However at the
>> moment, I receive after every run 2 mails from Box Backup with an unknow
>> error. The message in eventlog never showed that the notify script was
>> started with an unknow parameter, only backup-start/-finish/-ok. The
>> strange thing is that in the config file I have:
>>
>> NotifyScript = cscript "C:\Program Files\Box Backup\NotifySysAdmin.vbs"
>>
>> And I changed in that particular script the subjtmpl, but the mails remain the
>> same. Also I commented out the part of the unknown error, but still I receive
>> that kind of errors. I don't understand this, which script is executed? How
>> can I check this? And does Box Backup cache this script somewhere?
>>
>
> Box Backup doesn't cache the script, but is this on Windows Vista? If so,
> you may be editing a copy in the shadow directory in C:\Users\Your
> User\Local\Virtual Store\Program Files\Box Backup without realising it.
> The original copy would still be in C:\Program Files\Box Backup and
> bbackupd would still be running that copy. The easiest solution is to
> change your bbackupd.conf to point to the virtual store directory.
>
> Otherwise, please let us know what version of Windows you are running and
> please attach your current NotifySysAdmin.vbs and an example of the emails
> that you receive from it.
>
> Cheers, Chris.
>
Hi Chris,
I'm running Windows XP Pro, so no Vista here...
Copy of the notifyscript:
------------------------------------------------------------------------------
Dim hostname
Dim account
Dim from
Dim sendto
Dim subjtmpl
Dim subject
Dim body
Dim smtpserver
Set WshNet = CreateObject("WScript.Network")
hostname = WshNet.ComputerName
account = "0x1"
from = "<mail address>"
sendto = "<another mail address>"
smtpserver = "192.168.5.1"
subjtmpl = "(root) BACKUP PROBLEM on host " & hostname
Set args = WScript.Arguments
If args(0) = "store-full" Then
subject = subjtmpl & " (store full)"
body = "The store account for "&hostname&" is full." & vbCrLf & _
vbCrLf & _
"=============================" & vbCrLf & _
"FILES ARE NOT BEING BACKED UP" & vbCrLf & _
"=============================" & vbCrLf & _
vbCrLf & _
"Please adjust the limits on account "&account&" on server
"&hostname&"." _
& vbCrLf
SendMail from,sendto,subject,body
ElseIf args(0) = "read-error" Then
subject = subjtmpl & " (read errors)"
body = "Errors occured reading some files or directories for
backup on "&hostname&"." _
& vbCrLf & vbCrLf & _
"===================================" & vbCrLf & _
"THESE FILES ARE NOT BEING BACKED UP" & vbCrLf & _
"===================================" & vbCrLf & vbCrLf & _
"Check the logs on "&hostname&" for the files and
directories which caused" & _
"these errors, and take appropraite action." & vbCrLf &
vbCrLf & _
"Other files are being backed up." & vbCrLf
SendMail from,sendto,subject,body
ElseIf args(0) = "backup-error" Then
subject = subjtmpl & " (read errors)"
body = "An error occurred during the backup on "&hostname&"." _
& vbCrLf & vbCrLf & _
"==========================" & vbCrLf & _
"FILES MAY NOT BE BACKED UP" & vbCrLf & _
"==========================" & vbCrLf & _
vbCrLf & _
"Check the logs on "&hostname&" for more " & _
"information about the error, " & vbCrLf & _
"and take appropriate action." & vbCrLf
SendMail from,sendto,subject,body
ElseIf args(0) = "backup-start" Or args(0) = "backup-finish" Or args(0)
= "backup-ok" Then
' do nothing for these messages by default
'Else
' subject = subjtmpl & " (unknown)"
' body = "The backup daemon on "&hostname&" reported an unknown
error. Argument: "&args(0)&" | " _
' & vbCrLf & vbCrLf & _
' "==========================" & vbCrLf & _
' "FILES MAY NOT BE BACKED UP" & vbCrLf & _
' "==========================" & vbCrLf & vbCrLf & _
' "Please check the logs on "&hostname&"." & vbCrLf
' 'SendMail from,sendto,subject,body
End If
Function CheckSMTPSvc()
Set objWMISvc = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colSMTPSvc = objWMISvc.ExecQuery("Select * From Win32_Service " _
& "Where Name='SMTPSVC'")
If colSMTPSvc.Count > 0 Then
CheckSMTPSvc = True
Else
CheckSMTPSvc = False
End If
End Function
Sub SendMail(from,sendto,subject,body)
Set objEmail = CreateObject("CDO.Message")
Set WshShell = CreateObject("WScript.Shell")
Dim cdoschema
cdoschema = "http://schemas.microsoft.com/cdo/configuration/"
With objEmail
.From = from
.To = sendto
.Subject = subject
.TextBody = body
If CheckSMTPSvc = False Then
.Configuration.Fields.Item(cdoschema & "sendusing") = 2
.Configuration.Fields.Item(cdoschema & "smtpserver") =
smtpserver
.Configuration.Fields.Item(cdoschema & "smtpserverport") = 25
.Configuration.Fields.Update
End If
End With
On Error Resume Next
rc = objEmail.Send
If rc Then
WshShell.Exec "eventcreate /L Application /ID 201 /T WARNING " _
& "/SO ""Box Backup"" /D """ & args(0) _
& " notification sent to " & sendto & "."""
Else
WshShell.Exec "eventcreate /L Application /ID 202 /T ERROR " _
& "/SO ""Box Backup"" /D ""Failed to send " & args(0) _
& " notification to " & sendto & "."""
End If
End Sub
------------------------------------------------------------------------------
Copy of the mail I receive:
The backup daemon on hz-server reported an unknown error.
==========================
FILES MAY NOT BE BACKED UP
==========================
Please check the logs on hz-server.
Cheers,
Roy