Northstar Research Partners

Subscribe to this Blog

 

Contact Us!

 
AppTheory wants to talk to you about your business requirements.

Click Contact to fill out an online requirements questionnaire.

Thanks!

 

SharePoint Blogs

 

Current Articles | Archives | Search

Basic Powershell Backup Functions for Sharepoint 2007

When I first started working with Sharepoint 2007 I was frustrated having to use Central Administration to perform backups.  I personally prefer the command line.  I wanted a way to quickly perform farm backups and individual site backups without starting up Central Admin.  Fortunately stsadm.exe and Powershell came to my rescue.  Below are two functions that I first made to perform farm and site backups. 

Steps to use the scripts

  1. Add C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin added to your path .
  2. Add these scripts to profile file in Powershell.
  3. Create a shared directory for the backups. Make sure you have same permissions on the share as you would if backing up through Central Admin. This folder is basically a hot folder for instant backups.

$HotFolder = "E:\Backup\HotBackup\" + (Get-Date).dayofweek + "\"

function SpFarmBackup
{   
    if (Test-Path $HotFolder)
    {
        Remove-Item $HotFolder -recurse
        New-Item $HotFolder -type directory
    }
    else
    {
    New-Item $HotFolder -type directory
    }
$cmd = "stsadm -o backup -backupmethod full -directory " + $HotFolder + " -overwrite"
& cmd /c $cmd   

}

function SpWebBackup ( $SiteName, $FileName)
{
    $Backup = $HotFolder + $FileName + ".bak"
    $cmd = "stsadm -o export -url " + """$SiteName""" + " -includeusersecurity -filename " + """$Backup""" + " -overwrite"
    cmd /c $cmd
}

In my next post I will show you a more robust backup solution for Sharepoint with Powershell.  


COMMENTS

Name (required)

Email (required)

Website

Enter the code shown above:

Privacy Statement | Terms Of Use
Copyright © 2008 AppTheory
Trend Influence TrendCRM AppTheory