Free SharePoint Backups (2 of 4)

SharePoint
This entry is part 2 of 4 in the series Free SharePoint Backups

In the first article, I showed you one way to use a Windows script, batch file and task scheduler to perform a backup of each Site Collection in your farm.

Next up: Backing up the entire farm

This is really very simple. As you may know, you can use the Backup/Restore function in the SharePoint Central Administration interface. Unfortunately, you can’t schedule that. The solution is to use STSADM instead. This small batch file will log the time your backup starts and completes. It uses STSADM to backup the farm to a file share. Additionally, so we don’t have to login to go check out this log file, we can have it emailed to us.

Step 1:
Create the batch file using notepad or another text editor (I like Notepad++)

1
2
3
4
5
6
7
8
9
10
@ECHO OFF
@ECHO ================================================
@ECHO Backup Script For Office SharePoint Server 2007
@ECHO        Written By: Wahid Saleemi
@ECHO ================================================
@ECHO %date - %time% Backup Started >> D:\BackupBatch\farmbackup.log
stsadm -o backup -backupmethod full -directory \\Backups\Farm -overwrite
@ECHO %date - %time% Backup Complete >> D:\BackupBatch\farmbackup.log
@ECHO Execute the reporter script to email us that backups are done.
cscript D:\BackupBatch\reportfarm.vbs

Step 2:
Create a scheduled task that calls the batch file. I set mine to run using the farm service account at 3am everyday.

Step 3:
Create the vbs file using notepad, paste the following lines in.

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
'--------------------
' Send Email
'--------------------
Dim FSO, objShell
Dim strVirt, strPath, strReportTo
Dim strFileName, strTempFile, strLogFile
Dim dtmThisMinute, dtmThisHour
Dim dtmThisDay, dtmThisMonth, dtmThisYear
 
'dtmThisSecond = PadDigits(Second(Now), 2)
'dtmThisMinute = PadDigits(Minute(Now), 2)
'dtmThisHour = PadDigits(Hour(Now), 2)
'dtmThisDay = PadDigits(Day(Now), 2)
'dtmThisMonth = PadDigits(Month(Now), 2)
'dtmThisYear = Year(Now)
 
	' Define consts
	Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
	Const cdoSendUsingPort = 2
	Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
 
	' This is the sender of the report
	strVirt = "http://sharepoint.domain.com"
	strSMTPServer = "mailserver1"
	strReportTo = "portaladmin@domain.com"
	strFrom = "report@domain.com"
	strLogFile = "D:\BackupBatch\farmbackup.log"	
 
	' This is the subject
	strSubject = "MOSS Farm-level Backup Report for " & dtmThisYear & "-" & dtmThisMonth & "-" & dtmThisDay & "-" & dtmThisHour
 
	Set objMessage = CreateObject("CDO.Message")
	Set objConfig = CreateObject("CDO.Configuration")
	Set objFields = objConfig.Fields
 
	With objFields
		.Item(cdoSendUsingMethod) = cdoSendUsingPort
		.Item(cdoSMTPServer) = strSMTPServer
		.Update
	End With
 
	With objMessage
		Set .Configuration = objConfig
			.To = strReportTo
			.From = strFrom
			.Subject = strSubject
			.AddAttachment strLogFile
			.HTMLBody = "Attached is your farm-level backup for " & strVirt
	End With
 
	objMessage.Send
 
	Set objMessage = Nothing
	Set objConfig = Nothing
	Set objFields = Nothing
	strHTMLBody = vbNullString
    strFrom = vbNullString
    strSubject = vbNullString
	arrEmailAddress = vbNullString
	intArraySize = vbNullString

Remember to change the str values to your own. (By the way, anyone knows an easier way to do this, let me know! I know the vbscript needs to be cleaned up).

This post showed you how to automate farm-level backups using the free Windows tools and commands available to you. The files are sent to a fire share. That file share can be backed up to tape or disk for archiving if you needed.
Next up, I’ll show you some other things you should backup, such as the 12 hive, and how you can schedule that as well.

email
Series NavigationFree SharePoint Backups (1 of 4)Free SharePoint Backups (3 of 4)
0 comments… add one

Leave a Comment

%d bloggers like this: