X

Thank you for sharing!

Your article was successfully shared with the contacts you provided.

A backup plan is an insurance policy for your data, providing a means to manage the risk of a system failure or human error that results in data loss. In law firms such as mine, Fenwick & West, where Microsoft SharePoint houses valuable content such as documents, wikis and calendars, it’s of paramount importance that we adequately insure against the loss of those information assets.

A SharePoint backup plan needs several elements to provide for complete and flexible recovery. Because firms running SharePoint already own most of the required tools, implementing such a plan need not be costly. However, one element is missing from the out-of-the-box toolkit: automated, site-level backup. In this article, I’ll explain the key components you’ll need for your SharePoint backup plan, and show you (or your SharePoint administrator) how to build and deploy this missing element.

A solid backup plan doesn’t need to be complicated. Backup software vendors would have you believe that only their product can field a robust and reliable backup strategy; that you must shell out a lot of cash, and commit significant system administration resources, in order to protect your SharePoint environment.

In many cases spending your firm’s scarce resources on additional backup technology is unnecessary, as you already own the required software. For a comprehensive backup plan you’ll need file-system and SQL database backups, as well as a means to recover any customizations to your SharePoint environment. You’ll also want site-level backup so you can quickly restore a single site collection if accidentally deleted, or if you want to roll back to a previous version of a site (you’ll find this particularly handy with “My Site“).

Note: Those new to SharePoint may find Microsoft’s nomenclature a bit confusing. In SharePoint, the terms “site” and “site collection” are sometimes used synonymously, other times not. What is true is that the most granular unit that can be backed up using the methods I describe below is a site collection.

ELEMENTS OF A SHAREPOINT BACKUP PLAN

Any SharePoint backup plan should include:

1. File system backup of all SharePoint servers, including registry and SharePoint files that may be subject to customization — to rebuild a new Web front-end server in case of hardware or operating system failure;

2. SQL Server backup of content and configuration databases — to restore a working copy of the SharePoint configuration and content databases, or rebuild new SQL Server(s) in case of hardware failure.

If you customize SharePoint by adding features, custom Web parts, graphic or other elements, you’ll also need source control (such as Visual SourceSafe from Microsoft) to allow rollback of errors introduced into your production environment via custom components such as Web parts, Web applications or CAML (XML) configuration files.

To round out your toolkit, I’ll show you how to create a site-level backup to allow you to recover individual site collections in case some unwanted edit needs to be rolled back or a site administrator accidentally deletes the entire site.

How you implement the above components will be determined in large part by the answers to the following two questions:

1. What is the maximum amount of data that you can afford to lose — your “Recovery Point Objective” in disaster recovery terminology?

2. What is the maximum time you can allow for recovery –- your “Recovery Time Objective”?

As the values of RPO and RTO decrease, the cost of your data insurance policy (your backup plan) in terms of software, hardware and human resources tends to increase. Can your firm afford to lose a day’s worth of edits (RPO) to your SharePoint sites and wait for up to four hours to be back online (RTO)? If so, a plan that includes nightly SQL and file system backups and a spare Windows server may suffice. On the other hand, if minutes count, real-time mirroring of data to SQL and SharePoint servers at a remote location may be the right choice.

The point is that there’s no “correct” answer to the question: “What’s the right backup plan for my firm?” The answer will depend on your firm’s needs and budget with respect to the data housed in SharePoint.

What about third-party backup and source control products?

Windows Server and SQL Server both come with functional backup applications at no additional cost, and if you have Visual Studio you already own a source control solution. This raises the question: “When should my firm consider a third-party backup or source control product?”

Dedicated backup products generally go well beyond the basics, and will add the most value in firms with a large number of servers and/or many locations. These products can ease the burden of managing many backup schedules and devices, as well as restoring from those devices.

High-end source control solutions are most appropriate for large and/or dispersed development teams. Smaller teams may do best with the basic source control found in Visual SourceSafe (part of Visual Studio) or with an open source alternative such as CVS.

Only you can decide whether a third-party backup or source control product is right for your firm. Armed with the knowledge that you may already own the necessary tools will put you in the best position to make that determination.

CREATING A BASIC SITE-LEVEL BACKUP

In this section I’ll describe two options for creating an automated site-level backup utility for SharePoint. Both options create one backup file for each site collection on your server which can subsequently be restored using SharePoint’s STSADM command-line utility. There are important differences between these two approaches, however. The first option uses a Windows script that calls the SharePoint STSADM command. This approach has the advantage that it does not require .NET programming, and thus may be more accessible to systems administrators who are comfortable creating script files, but not with developing applications using Visual Studio and C#. The downside of this approach is that it provides limited control over memory use, and thus may not be appropriate for large SharePoint installations.

The second option involves creating a C# application that calls the SharePoint API. While this approach requires a bit more work, it should be quite easy for anyone with access to Visual Studio 2005 or later, and a bit of programming experience. This option also gives you more control over memory use, and so can scale to very large installations.

Note: Both the script created in option No. 1 and the program created in option No. 2 must run from a front-end Web server that is part of your SharePoint farm. To implement either of the following solutions, you will need administrator rights on your SharePoint server.

OPTION NO. 1: SCRIPTING SITE-LEVEL BACKUP USING STSADM

If you are a SharePoint administrator, you’re probably familiar with the STSADM utility. This is a command-line utility that is installed with SharePoint (either MOSS or WSS), and is typically found in the “c:\program files\common files\microsoft shared\web server extensions\12\bin” folder on any SharePoint server. The STSADM utility supports numerous operations, two of which are BACKUP and RESTORE. The following script can be saved to a file on disk, and run using the Windows command prompt or task scheduler.

‘ ————————————————————–
‘ Purpose: Backup all SharePoint site collections on server
‘ ————————————————————–
Option Explicit

‘ Set the path to the STSADM utility
Const STSADM_PATH = _
“C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm”

‘ Set the path to where you want the backups made
Const BACKUP_PATH = “C:\SharePoint_Backups\”

‘ Define needed variables
Dim objFso, objFolder, objFiles, objFile, objShell
Dim objExec, strResult, objXml, objSc, objUrl
Dim strUrl, strFileName, strCmd

‘ Step 1: OPTIONAL: Delete any pre-existing backups
Set objFso = CreateObject(“Scripting.FileSystemObject”)
Set objFolder = objFso.GetFolder(BACKUP_PATH)
Set objFiles = objFolder.Files
For Each objFile in objFiles
objFile.Delete(True)
Next

‘ Step 2: Retrieve all site collections in XML format.
Set objShell = CreateObject(“WScript.Shell”)
Set objExec = objShell.Exec(STSADM_PATH & ” -O ENUMSITES -URL http://localhost/”)
strResult = objExec.StdOut.ReadAll

‘ Load XML in DOM document so it can be processed.
Set objXml = CreateObject(“MSXML2.DOMDocument”)
objXml.LoadXML(strResult)

‘ Step 3: Loop through each site collection and call stsadm.exe to make a backup.
For Each objSc in objXml.DocumentElement.ChildNodes
strUrl = objSc.Attributes.GetNamedItem(“Url”).Text
strFileName = BACKUP_PATH & _
Replace(Replace(strUrl,”/”,”_”),”:”,”") & “.bak”
strCmd = STSADM_PATH & ” -O BACKUP -URL “ ”" & _
strUrl + “”" -FILENAME “”" + strFileName + “”"”

‘ For testing, display pop-up for each collection backed up
WScript.Echo “Backing up site collection ” & _
strUrl & ” to file ” & _
strFileName & ” using the following command ” & _
strCmd
WScript.Echo

objShell.Exec(strCmd)

‘ Optional, if there will be many site collections, may want
‘ to insert a delay to avoid overloading server memory
GoSleep(3)

Next

‘ This function can be used to insert a delay in the processing
‘ to avoid overloading server memory if there are many
‘ site collections to be backed up.
Function GoSleep(seconds)
Dim startTime, endTime, nowTime, dummy
startTime = DateAdd(“s”,0,Now)
endTime = DateAdd(“s”,seconds,Now)
nowTime = DateAdd(“s”,0,Now)
While endTime > nowTime
‘ Need some commands lin while loop to
‘ ensure it actually executes
nowTime = DateAdd(“s”,0,Now)
dummy = Time
Wend
End Function

If you save the above script to a file named “Backup.vbs”, you would execute it using the command CSCRIPT BACKUP.VBS.

Running the above command from a command prompt will look something like the following screen shot:

Click image to enlarge
Figure 1: Output from command “cscript backup.vbs” Click image to enlarge.

And, assuming the script is set to write backup files to “C:\SharePoint_Backups,” you should find one or more BAK files in that folder after the script runs.

Click image to enlarge
Figure 2: Directory view of .bak files. Click image to enlarge.

OPTION NO. 2: PROGRAMMING SITE-LEVEL BACKUP USING C#

To create the following program you’ll need Microsoft Visual Studio 2005 or later. First create a new C# console application, then paste the code below into the “program.cs” file, add a reference to the Windows SharePoint Services assembly and, finally, click the compile button.

This will result in an executable that you can run from the Windows command prompt or the task scheduler. Note that if the SharePoint Web application you want to back up is on a non-standard port, or uses a host header, you will want to change the reference to http://localhost in the line site = new SPSite(“http://localhost”);.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Data;
using System.Configuration;

This content has been archived. It is available exclusively through our partner LexisNexis®.

To view this content, please continue to Lexis Advance®.

Not a Lexis Advance® Subscriber? Subscribe Now

Why am I seeing this?

LexisNexis® is now the exclusive third party online distributor of the broad collection of current and archived versions of ALM's legal news publications. LexisNexis® customers will be able to access and use ALM's content by subscribing to the LexisNexis® services via Lexis Advance®. This includes content from the National Law Journal®, The American Lawyer®, Law Technology News®, The New York Law Journal® and Corporate Counsel®, as well as ALM's other newspapers, directories, legal treatises, published and unpublished court opinions, and other sources of legal information.

ALM's content plays a significant role in your work and research, and now through this alliance LexisNexis® will bring you access to an even more comprehensive collection of legal content.

For questions call 1-877-256-2472 or contact us at customercare@alm.com

 
 

ALM Legal Publication Newsletters

Sign Up Today and Never Miss Another Story.

As part of your digital membership, you can sign up for an unlimited number of a wide range of complimentary newsletters. Visit your My Account page to make your selections. Get the timely legal news and critical analysis you cannot afford to miss. Tailored just for you. In your inbox. Every day.

Copyright © 2020 ALM Media Properties, LLC. All Rights Reserved.