in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

This Blog

Syndication

Tags

No tags have been created or used yet.

Archives

arjanp

PowerShell script to back-up site collections

 

This script enumerates the user web-applications and backups up all site collections on each of them in a separate folder.

 

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null
cls

$rootBackupStorage = "d:\backup\data"

write-host `n`n===================================================================================================
get-date

$oContentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;

[Microsoft.SharePoint.Administration.SPWebApplicationCollection]$waColl = $oContentService.WebApplications;

$waColl1 = $waColl | where-object {$_.IsAdministrationWebApplication -eq $FALSE}

foreach ($wa in $waColl1)
{

    $waName = $wa.Name

    write-host "`nVirtual Server: " $waName

    $sites = $wa.Sites

    write-host "Sites: " $sites.Count

    foreach ($obj in $sites)
    {
      $siteurl = $obj.Url.Replace("
http://","").Replace(":","").split("/")

       write-host "Backing up: " $obj.Url
      $dir = $siteurl[0]
      $site = [String]::Join("-",$siteUrl)
      $siteurl = $obj.Url

      New-item "$rootBackupStorage\$dir" -type directory -force | out-null

      #write-host "stsadm -o backup -url $siteurl -filename ""$rootBackupStorage\$dir\$site.backup"" -overwrite"
      stsadm -o backup -url $siteurl -filename "$rootBackupStorage\$dir\$site.backup" -overwrite

    }

}

Comments

 

Links (2/27/2008) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (2/27/2008) « Steve Pietrek’s SharePoint Stuff

February 27, 2008 7:16 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts