[Box Backup-dev] Re: [Box Backup] ChrisMerge_1828

James O'Gorman boxbackup-dev@fluffy.co.uk
Thu, 13 Sep 2007 21:14:28 +0100


--SWTRyWv/ijrBap1m
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, Sep 13, 2007 at 07:51:56PM +0100, Chris Wilson wrote:
>  Thanks for that! Out of interest, would it be possible to detect the lack of 
>  a working SMTP service and log an error in the Event Log? Would probably 
>  save people some head-scratching.

I think the attached should do the trick.

>  I'd say that sounds like a good idea, thanks.

OK, I've removed TICKET_CREATE from anonymous. I'll resolve all the spam
tickets. I was tempted to remove them from the database but that would
mean resetting the indexes...

On Thu, Sep 13, 2007 at 08:32:47PM +0100, Chris Wilson wrote:
>  Also, would it be possible to detect the hostname in some way rather than 
>  hard-coding "starbug.netinertia.co.uk" :-)

Whoops! Fixed. Can you guess which box I copied the script from? :-)
With regard to detecting the hostname... I didn't do that and just put
%%server%% placeholders for sed/awk/whatever to replace it when
bbackupd-config is run, just like the current one (ish). Otherwise it's
probably doable in WSH. Expect version 3 shortly :-)

James

--SWTRyWv/ijrBap1m
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="NotifySysAdmin.vbs"

Dim from
Dim sendto
Dim subjtmpl
Dim subject
Dim body
Dim smtpserver

from = "boxbackup@%%server%%"
sendto = "admin@example.com"
subjtmpl = "BACKUP PROBLEM on host %%server%%"
smtpserver = "smtp.example.com"

Set args = WScript.Arguments

If args(0) = "store-full" Then
	subject = subjtmpl & " (store full)"
	body =	"The store account for %%server% is full." & vbCrLf & vbCrLf & _
			"=============================" & vbCrLf & _
			"FILES ARE NOT BEING BACKED UP" & vbCrLf & _
			"=============================" & vbCrLf & vbCrLf & _
			"Please adjust the limits on account %%account%% on server %%server%%." _
			& 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 %%server%%." _
			& vbCrLf & vbCrLf & _
			"===================================" & vbCrLf & _
			"THESE FILES ARE NOT BEING BACKED UP" & vbCrLf & _
			"===================================" & vbCrLf & vbCrLf & _
			"Check the logs on %%server%% 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
Else
	subject = subjtmpl & " (unknown)"
	body =	"The store account for %%server% is full." & vbCrLf & vbCrLf & _
			"==========================" & vbCrLf & _
			"FILES MAY NOT BE BACKED UP" & vbCrLf & _
			"==========================" & vbCrLf & vbCrLf & _
			"Please check the logs on %%server%%." & 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")
	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
	objEmail.Send
End Sub

--SWTRyWv/ijrBap1m--