Advertisement

07.21.2008 at 01:54AM PDT, ID: 23581177
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

MOSS 2007 VBS Backup Script Fails when used as Scheduled Job but not as standalone

Asked by ensermo in MOSS-Sharepoint, Microsoft Visual Basic.Net, VB Script

Tags: , , ,

We have a MOSS 2007 backup script we got from the Internet to perform a daily full site backup via Scheduled Jobs.

The strange thing is. When we use this script as "standalone" (thus clicking on it and just running) it works fine. After about 20-30 minutes the backup is succesfully finished. We receve an e-mail and all is good.

But when we run the script on a nightly scheduled task. We end up receving thousands of e-mails in our mailbox
"SharePoint Backup Process exceeded 120 minutes", "SharePoint backup process has been running for over 120 minutes.Please check progress of backup"

This "e-mail" notification doesn't stop until we log into the server and kill the backup process (or the scheduled task kills it after running too long).

I have looked at the script and while Im not a programming guru I believe there is nothing wrong with it.
So I am wondering. Dus running this script as a scheduled task has some commands that aren't allowed or won't run correctly?

Why does the "wait loop" run forever when doing a scheduled task  (and sends thousands of e-mails) but when ran standalone there are no problems?

Any programming gurus can help?

PS. Don't know if it is relevant but this is running on a 64bit version of Windows 2003 and MOSS 64bit.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
' Email source address
Const strFrom = "mossbackup@mymossserver.com"
 
'Email destination address
Const strTo = "michael@myownserver.com"
 
' Mail server address
Const strMailserver = "mymailserver.wan"
 
' Create variable used to contain the name of day
Dim varWeekDay
varWeekDay = (WeekdayName(Weekday(date)))
 
Set objShell = CreateObject("WScript.Shell")
 
' Obtain the path where stsadm is located on the server
Dim strRegKey
strRegKey = objShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Location")
 
Dim strMOSSPath
strMOSSPath = strRegKey & "BIN\"
 
Dim strBackupLocation
strBackupLocation = "\\lanserver\SharepointBackup\" & varWeekDay
 
' Define the path to SharePoint Backup Restore Table file which contains
' crucial information regarding the outcome of the backup
Dim SharPointBackupRestoreTable
SharPointBackupRestoreTable = strBackupLocation & "\spbrtoc.xml"
 
 
Call deleteBackupFolder (strBackupLocation)
 
'Ensure the script runs in the SharePoint directory
objShell.CurrentDirectory = strMOSSPath
 
' Execute stsadm backup command
objShell.Exec ("stsadm -o backup -directory " & strBackupLocation & " -backupmethod full")
 
' This Do loop checks the status of the backup process every minute.
' If the backup process hasn't completed within 60 minutes an email is sent to the
' Sharepoint administrator notifying him/her about this, otherwise an email is sent
' notifying the SharePoint Administrator of the outcome of the backup
Do
loopCounter = loopCounter + 1
 
If count > 120 Then
Call SendEmail("SharePoint Backup Process exceeded 120 minutes", "SharePoint backup process has been running for over 120 minutes.Please check progress of backup")
End If
 
' Wait for 1 minute
WScript.Sleep 60000
 
' Check if the backup process (i.e. stsadm.exe) is currently running
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set sharepointProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'stsadm.exe'")
 
If (sharepointProcess.count) = 0 Then
' Backup process has ended therefore check the SharePoint Backup Restore Table to analyse the outcome of the backup
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load(SharPointBackupRestoreTable)
Set NodeList = objXMLDoc.documentElement.selectNodes("//SPErrorCount")
For Each Node In NodeList
If (Node.text) <> "0" Then
' Backup errors were generated
Call SendEmail("SharePoint backup Failed", "SharePoint backup failed with errors. Please investigate backup logs")
Else
' No backup errors were generated
Call SendEmail("SharePoint backup successfully completed", "SharePoint backup completed without errors")
End If
Next
 
Exit Do
End If
 
 
Loop
 
 
'Sends email with status of backups
Sub SendEmail (subject, body)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = subject
objEmail.Textbody = body
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strMailserver
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Call WriteEvent(subject,body)
End Sub
 
' Log the backup outcome to server application event log
Sub WriteEvent(subject,body)
If subject = "SharePoint backup successfully completed" Then
objShell.LogEvent 0, body
Else
objShell.LogEvent 1, body
end If
End Sub
 
Sub deleteBackupFolder (backupLocation)
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(backupLocation)) Then
' Delete existing backup folder
fso.DeleteFolder(backupLocation)
' Create new backup folder
fso.createFolder(backupLocation)
Else
' Folder not present therefore create new folder
fso.createFolder(backupLocation)
End If
End Sub
[+][-]07.21.2008 at 02:05AM PDT, ID: 22048906

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.21.2008 at 02:32AM PDT, ID: 22049003

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.21.2008 at 02:50AM PDT, ID: 22049083

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.21.2008 at 05:34AM PDT, ID: 22049828

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MOSS-Sharepoint, Microsoft Visual Basic.Net, VB Script
Tags: Microsoft, Office Sharepoint Server, 2007, on Windows 2003 Server Std R2
Sign Up Now!
Solution Provided By: ensermo
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628