Showing posts with label VBScript. Show all posts
Showing posts with label VBScript. Show all posts

Friday, February 02, 2007

VBScript for SharePoint 2007 backup

Rem The VBScript was created by Boris Sirotin All Covered 02/02/2007
Rem Copy stsadm.exe to same folder with the script
Rem The script should be scheduled as a task
Rem It will backup sharepoint to folder, by Friday it will run full backup and delete all backups
Rem older then 2 weeks. All other days it will run differential

Dim weekdate, weekdate1, command1, command2, oFSO, backpath1,backpath2,myFolder, f
Set Sh = Wscript.CreateObject("Wscript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
weekdate=datepart("w",date)
backpath="file://vega/sharepoint/weekly"
Set myFolder=oFSO.GetFolder(backpath)
command1="stsadm -o backup -directory " +backpath + " -backupmethod full"
command2="stsadm -o backup -directory " +backpath + " -backupmethod differential"
if weekdate=6 Then
CleanUp(myFolder)
Sh.run command1, 1
else
Sh.run command2, 1
end if
Function CleanUp (Folder)
For Each f In Folder.SubFolders
If DateDiff("d",Now,f.DateCreated,vbMonday)>2 then
f.Delete
End if
next
End function