Wednesday, October 28, 2009

Creating an automated Back up of SharePoint/MOSS site collection

Here are the steps to be followed to create an automated back up of the site collection. This Script come in handy for any SharePoint/MOSS administrator

1. Create a text file and copy the following code into it

'''''''''''''
'Begin Script
'''''''''''''
Dim fso, f, fspec
dim yr, mo, dt, hr, min, sec

yr = Year(Now)

mo = Month(Now)
if mo < 10 Then
mo = "0" & mo
end if

dt = Day(Now)
if dt < 10 Then
dt = "0" & dt
end if

hr = Hour(Now)
if hr < 10 Then
hr = "0" & hr
end if

min = Minute(Now)
if min < 10 Then
min = "0" & min
end if

sec = Second(Now)
if sec < 10 Then
sec = "0" & sec
end if

FileName ="FILENAME_" & yr & "_" & mo & "_" & dt & "_" & hr & "_" & min & "_" & sec

'''''''''''''''''''''''''
'Run the spsbackup script
'''''''''''''''''''''''''
Set objShell = CreateObject("WScript.Shell")
objShell.CurrentDirectory = "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"

objShell.Exec ("stsadm.exe -o backup -url http://SiteCollection/ -filename ""E:\"& FileName & ".dat""")

Step 2: Rename the extension as .VBS and place it C:\ drive
Step 3: Double click on the .VBS file and check once if the back up happening properly.

Note: the back up may not happen if either site collection or path to save is wrong. And also if you don't have the rights to take back up of site collection or write permission in the save path

Step 4:Once successful back up is taken, you can create a schedule task for taking back up at regular interval

Note: In case you are working for an organisation where your pass word need to be changed after stipulated time span, don't use a domain account as the back up may stop when password is changed and you need to reset it for the schedule task. Use a local account with enough privilege

No comments:

Post a Comment