Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backing up SharePoint Portal Server

Status
Not open for further replies.

sgwisby

Technical User
Apr 13, 2005
148
US
Is it sufficient to use just the SQL's Enterprise Manager to create backups of the SharePoint Portal Server databases or should the SharePoint utilities(SPS and STSADM)be used as well?
I am actually using the stsadm and SQL backup utilities right now and wasn't sure if I had everything I needed or if I had too much.
Thanks
David
 
Hello,

We are running the same way you are and in addition to that I am using a 3rd party backup software for itemlevel backup on our sites.

Only using the SQL backup feature from Enteprise manager is not enough if you need to restore certain sites.

So I would recommend you to keep running the way you are, it is better to have to much backup than to little.

Cheers,
Thomas



 
I agree, the only time you'll appreciate several levels of backup is when you need to resotre. I have 3 scripts I use daily. They have saved my butt many times. here they are.

This script will enumerate all of the sites and back them up individually. You have to change the path where you want to save the backed up files.

Code:
Option Explicit
Const STSADM_PATH = "C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BIN\stsadm"
Dim objFso, objFolder, objFiles, objFile, objShell, objExec, strResult, objXml, objSc, objUrl, strUrl, strFileName, strCmd
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder("\\portal\Backups$\WSSBackups\")
Set objFiles = objFolder.Files
'WScript.Echo "Begin backup"
For Each objFile in objFiles 
	objFile.Delete(True)
	Next
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec(STSADM_PATH & " -o enumsites -url [URL unfurl="true"]http://portal")[/URL]
strResult = objExec.StdOut.ReadAll
'WScript.Echo strResult
Set objXml = CreateObject("MSXML2.DOMDocument")
objXml.LoadXML(strResult)
For Each objSc in objXml.DocumentElement.ChildNodes 
strUrl = objSc.Attributes.GetNamedItem("Url").Text 
strFileName = "\\portal\Backups$\WSSBackups\" & Replace(Replace(strUrl, "[URL unfurl="true"]http://",[/URL] ""), "/", "_") & ".bak" 
strCmd = STSADM_Path & " -o backup -url """ + strUrl + """ -filename """ + strFileName + """" 
'WScript.Echo "Backing up site collection " & strUrl & " to file " & strFileName & " using the following command " & strCmd  
objShell.Exec(strCmd)
Next
'WScript.Echo "Backup of portal site collections successful"

The second one backups up the entire portal
Code:
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1
'
' NAME: sharepoint backup wrapper Version 1.0
'
' AUTHOR: Bart Bultinck , Dolmen Computer Applications
' DATE : 4/03/2004
'
' COMMENT: 
' Based on some info found
'==========================================================================
option Explicit
Dim wShell, stringbuild

' complete path to spsbackup.Exe
Const backupexefile = "C:\Program Files\SharePoint Portal Server\Bin\spsbackup.exe" 
' path name use no spaces
Const BackupDestinationFolder = "\\portal\Backups$\SPSBackups\"
' choose a prefix relevant to your portal (eg the name)
Const BackupPrefix = "portal"

'shell out to command prompt
Set wShell = wscript.CreateObject("wscript.shell") 
'build the string to run in command prompt
stringbuild = Chr(34) & backupexefile & Chr(34) & " /all /file " & Chr(34) & BackupDestinationFolder & BackupPrefix & Chr(34) & " " & "/overwrite"
'WScript.Echo stringbuild
wShell.Run stringbuild

'==========================================================================

The last backs up the iis metabase
Code:
'****************************************
' Description:
'   Metabase Backup Utility
' Syntax:
'   CSCRIPT MBACKUP.VBS
'****************************************

Option Explicit
On Error Resume Next

' Declare variables.
Dim strBackupName, lngBackupVersion, lngBackupFlags
Dim objComputer
Dim strDay, strMonth, strYear, strComputer

'Get the machine name
Set objComputer = CreateObject("Shell.LocalMachine")
strComputer = objComputer.MachineName

' Get the current DD/MM/YY as strings.
strDay   = Right("00" & Cstr(Day(Date())),2)
strMonth = Right("00" & Cstr(Month(Date())),2)
strYear  = Cstr(Year(Date()))


' Create a file name from the current date.
strBackupName = strComputer & "_" & strMonth & "-" & strDay & "-" & strYear

' Use the next available version number.
lngBackupVersion = &HFFFFFFFF
lngBackupFlags = 0

' Output the backup message.
'Wscript.Echo "Backing up metabase to file: """ & strBackupName & """"

' Get the ADSI object.
Set objComputer = GetObject("IIS://LOCALHOST")

' Call the backup method.
objComputer.BackupWithPassword strBackupName, lngBackupVersion, lngBackupFlags, "password"

' Check for errors.
'If Err.Number <> 0 Then
'  Wscript.Echo "Error: "  & Err.Description & " (0x" & Right(String(8,"0") & Hex(Err.Number),8) & ")"
'Else
'  Wscript.Echo "Success."
'End If

'****************************************
' The remaining code is optional and deletes a specific older backup.
'****************************************

' The value of lngBackupToDelete determines which specific date to delete
' in this case. 28 days is four weeks ago if you are running a weekly backup.
Const lngBackupToDelete = 28

' Declare variables.
Dim strOldDay, strOldMonth, strOldYear, strOldBackupName

' Get the old DD/MM/YY as strings.
strOldDay   = Right("00" & Cstr(Day(Date()-lngBackupToDelete)),2)
strOldMonth = Right("00" & Cstr(Month(Date()-lngBackupToDelete)),2)
strOldYear  = Cstr(Year(Date()-lngBackupToDelete))

' Create the file name from the old date.
strOldBackupName = strComputer & "_" & strOldMonth & "-" & strOldDay & "-" & strOldYear

' Output the deletion message.
'Wscript.Echo "Deleting metabase backup file: """ & strOldBackupName & """"

' Call the deletion method.
objComputer.DeleteBackup strOldBackupName, 0

' Check for errors.
'If Err.Number <> 0 Then
'  If Err.Number = &H80070002 Then
'    Wscript.Echo "File not found."
'  Else
'    Wscript.Echo "Error: "  & Err.Description & " (0x" & Right(String(8,"0") & Hex(Err.Number),8) & ")"
'  End If
'Else
'  Wscript.Echo "Success."
'End If

'****************************************
' This will copy the metabase files to the D share.
'****************************************

Dim objFSO

CopyAFile "C:\WINDOWS\system32\inetsrv\MetaBack\portal*.*" , "\\portal\Backups$\MetaBase\"

Sub CopyAFile(vFrom, vTo)

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile vFrom, vTo, True
objFSO.CopyFile "C:\WINDOWS\system32\inetsrv\MetaBack\portal*.*" ,"\\portal\Backups$\MetaBase\", True
Set objFSO = Nothing

End Sub
That should cover it.
 
Sorry I forgot. Put them on the portal (C:\) and run them with a schedule every night.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top