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")
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) command1, 1
else command2, 1
end if
Function CleanUp (Folder)
For Each f In Folder.SubFolders
If DateDiff("d",Now,f.DateCreated,vbMonday)>2 then
End if
End function

No comments:

Post a Comment