24 de septiembre de 2008

Backup SharePoint My Sites

Interesante Script que nos permite Respaldar nuestras bases de contenido de los My Sites… desde el Blog de Chris Ogle, pueden ver el articulo Original AQUI

' BackupMysites.vbs
'
' Get a list of all MySites from SharePoint, then back them up.
' You must run this script using CScript, like this:
' cscript BackupMysites.vbs <hostname:port> <destination>
'

' Get command line arguments
If Wscript.Arguments.Count <> 2 Then
Wscript.Echo "usage: cscript BackupMysites.vbs <hostname:port> <destination>"
Else
HOSTNAME = WScript.Arguments(0)
DESTINATION = WScript.Arguments(1)

' Define useful constants.
HOST = "http://" & HOSTNAME
URLPREFIX = HOST & "/personal/"
STSADM = """C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe"""

' Execute stsadm.exe to get a list of all MySites.
' Write the list to an xml file.
' Wait for it to finish.
set wshell = CreateObject("WScript.Shell")
CmdString = STSADM & " -o enumsites -url " & HOST & " > SiteList.txt"
wshell.run "%comspec% /c " & CmdString, 1, True
set wshell = nothing

' Read xml file containing a list of all MySites.
dim mydoc
set mydoc=CreateObject("Microsoft.XMLDOM")
mydoc.async=false
mydoc.load("SiteList.txt")
if mydoc.parseError.errorcode<>0 then
  'msgbox("Error - mydoc.load error " & mydoc.parseError.reason)
  WScript.StdOut.Write "Error opening input file '" & "SiteList.txt" & "' - " & mydoc.parseError.reason
else
  ' For each MySite in the list...
  for each x in mydoc.documentElement.childNodes
   ' For each attribute of the site...
   for each a in x.Attributes
    ' If this is the "Url" attribute...
    if a.Name = "Url" then
     'msgbox x.nodeName & ": " & a.Name & " = " & a.value & vbcrlf & "URLPREFIX = " & URLPREFIX
     ' The list contains a few sites we don't care about.
     ' We care about those that start with URLPREFIX.
     if LCase(Left(a.value,Len(URLPREFIX))) = LCAse(URLPREFIX) Then
      ' Extract the user name from the url.
      dim UserName
      UserName = Right(a.Value,Len(a.Value)-Len(URLPREFIX))
      ' Execute stsadm.exe to back up the site.
      ' Wait for it to finish.
      set wshell = CreateObject("WScript.Shell")
      CmdString = STSADM & " -o backup -url " & URLPREFIX & UserName & " -filename " & DESTINATION & "\MySites\" & UserName & ".bak"
      wshell.run "%comspec% /c " & CmdString, 1, True
      set wshell = nothing
     end if
    end if
   next
  next
end if
end if

No hay comentarios.: