I use the following vbs file - see code below (works for me) and I did
not write myself and acknowledge
(http://www.awomantoldme.com/women/how-to/31059831/backup-rotation-any-t
hou.aspx)
<number of days> <path>
i.e backupCleanUp.vbs 14 e:\sharepoint\spbrtoc.xml - will delete backups
older than 14 days
' Title: BackupCleanUp
' Description: Deletes SharePoint 2007 backups that are older than a
specified
' number of days and then removes the backups from the
backup history.
Dim nNumberOfDays
Dim strTOCFile
Dim dtDeleteDate
Set objXML = CreateObject("Microsoft.XMLDOM")
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objLog = objFS.OpenTextFile("BackupCleanUp.log",8,true)
' Validate command line arguments and initialize data.
If WScript.Arguments.Count = 2 Then
If IsNumeric(WScript.Arguments(0)) Then
nNumberOfDays = CInt(WScript.Arguments(0))
dtDeleteDate = DateAdd("d",nNumberOfDays*-1,Now)
Else
WScript.Echo "<NumberOfDays> must be an integer value."
End If
strTOCFile = WScript.Arguments(1)
Else
WScript.Echo "Usage: BackupCleanUp <NumberOfDays> <PathToTOC>"
WScript.Quit
End If
objLog.WriteLine(Now() &vbTab& "Start: Clean up backups older than "
&nNumberOfDays& " days from " &strTOCFile& ".")
' Load the SharePoint backup and restore the TOC file.
objXML.Async = false
objXML.Load(strTOCFile)
If objXML.ParseError.ErrorCode <> 0 Then
objLog.WriteLine(Now() &vbTab& "Error: Could not load the SharePoint
Backup / Restore History." &vbCrLf& Now() &vbTab& "Reason: "
&objXML.ParseError.Reason& ".")
WScript.Quit
End If
' Delete backup nodes that are older than the deletion date.
For Each objNode in objXML.DocumentElement.ChildNodes
If CDate(objNode.SelectSingleNode("SPFinishTime").Text) <
dtDeleteDate Then
If objNode.SelectSingleNode("SPIsBackup").Text = "True" Then
if
objFS.FolderExists(left(objNode.SelectSingleNode("SPBackupDirectory").Te
xt, len(objNode.SelectSingleNode("SPBackupDirectory").Text)-1)) then
objFS.DeleteFolder(left(objNode.SelectSingleNode("SPBackupDirectory").Te
xt, len(objNode.SelectSingleNode("SPBackupDirectory").Text)-1))
else
objLog.WriteLine(Now() &vbTab& "Error: Folder found in
xml backup file, does not exist on drive, cannot delete it " &vbCrLf&_
Now() &vbTab&
left(objNode.SelectSingleNode("SPBackupDirectory").Text,len(objNode.Sele
ctSingleNode("SPBackupDirectory").Text)-1) & " .")
End if
objLog.WriteLine(Now() &vbTab& "Deleted: "
&objNode.SelectSingleNode("SPBackupDirectory").Text& ".")
objXML.DocumentElement.RemoveChild(objNode)
End If
End If
Next
' Save the XML file with the old nodes removed.
objXML.Save(strTOCFile)
objLog.WriteLine(Now() &vbTab& "Finish: Completed backup clean up.")
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of MacDonald, Mike
Sent: Friday, 8 February 2008 12:32 PM
To: [email protected]
Subject: RE: [OzMOSS] Overwriting spbr### backup folder
I do not know what that is..?
Thank you,
Mike MacDonald
Securian Financial Group
Individual Business Technology
1-800-395-2774 opt 4 - 1
fax: 651-665-5860
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Aaron Saikovski
Sent: Thursday, February 07, 2008 6:21 PM
To: [email protected]
Subject: RE: [OzMOSS] Overwriting spbr### backup folder
Hi Mike,
I haven't myself but maybe you could use a powershell cmdlet to do it
for you?
Just a thought.
Cheers,
Aaron
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of MacDonald, Mike
Sent: Friday, 8 February 2008 7:14 AM
To: [email protected]
Subject: [OzMOSS] Overwriting spbr### backup folder
Hi all:
I have created a batch file to run the backup command line on a
scheduled task daily.
@ECHO OFF
CD C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN
stsadm -o backup -url http://securiantechnology/ -filename spbackup.bak
-overwrite -directory \\mmsibt07\backup\sharepoint -backupmethod full
However I cannot get it to remove the old backup spbr#### folder. Has
anyone successfully solved this problem?
Thank you,
Mike MacDonald
Securian Financial Group
Individual Business Technology
1-800-395-2774 opt 4 - 1
fax: 651-665-5860
-------------------------------------------------------------------
OzMOSS.com - to unsubscribe from this list, send a message back to the
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net
-------------------------------------------------------------------
OzMOSS.com - to unsubscribe from this list, send a message back to the
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net
-------------------------------------------------------------------
OzMOSS.com - to unsubscribe from this list, send a message back to the
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net
------------------------------------------------------------------- OzMOSS.com
- to unsubscribe from this list, send a message back to the list with
'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net