' Distributed by Leb Shama Company Limited ' This script works only in Windows OS ' The directory which stores the sharepoint backup Const BackupDirectory = "D:\BackupDir" ' This is the default path of stsadm.exe. If you have different settings, please find out the absolute path of the execute file. Const StsadmExecPath = "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" ' BackupDate is now set to the current date Dim BackupDate: BackupDate = Date select case Weekday(BackupDate) 'Please change your schedule here if necessary case vbSunday Call BackupFull case vbMonday Call BackupDiff case vbTuesday Call BackupDiff case vbWednesday Call BackupDiff case vbThursday Call BackupDiff case vbFriday Call BackupDiff case vbSaturday Call BackupDiff end select ' This Sub will perform a differential backup of Sharepoint Sub BackupDiff Dim objShell Set objShell = wscript.createObject("WScript.Shell") Call objShell.Run("""" & StsadmExecPath & """ -o backup -directory """ & BackupDirectory & """ -backupmethod differential -quiet",0, 1) end Sub ' This Sub will delete all the contents inside the BackupDirectory and then perform a full backup of Sharepoint Sub BackupFull DelFiles(BackupDirectory) DelSubFolders(BackupDirectory) Dim objShell Set objShell = wscript.createObject("WScript.Shell") Call objShell.Run("""" & StsadmExecPath & """ -o backup -directory """ & BackupDirectory & """ -backupmethod full -quiet",0, 1) end Sub Sub DelFiles(path) Set fso=CreateObject("Scripting.FileSystemObject") For Each file In fso.GetFolder(path).Files file.attributes = file.attributes And Not 1 file.delete Next End Sub Sub DelSubFolders(path) Set fso=CreateObject("Scripting.FileSystemObject") For Each subfolder In fso.GetFolder(path).SubFolders DelSubFolders(subfolder) subfolder.attributes = subfolder.attributes And Not 1 subfolder.delete Next End Sub