Every Techie needs to read something.

Showing posts with label DisasterRecovery. Show all posts
Showing posts with label DisasterRecovery. Show all posts

Tuesday, June 19, 2007

Script to backup SharePoint Team Services 2

Over at my very popular "Strange SharePoint Restore Issue" post, Rafael was having a problem with restoring a SharePoint backup. Unfortunately it isn't anything I have ran into, all of my experience has been with SharePoint Team Services 2. But Rafael asked me to post my SharePoint backup script anyway.

So here it is, but first, a little advice:

If you use this script to backup your SharePoint database:

  • As with any backup plan or device, Test out the restore procedure.
  • Backups are Version Dependent. There are various subversions. Here is a Penny Coventry (MVP) has a nice table that lays out the versions.
  • Make sure that the name remains the same. If you rename the backup file before you try to restore it, you will get a strange error.
  • Use this script at your own peril. I don't guarantee anything. This works for me, and I have tested it in my environment. You should do the same before you rely on it.
  • The script makes files named "YYYY-M-D-SharepointBackup.dat". You should only run it once a day, or it will error out the next runs.
  • I run this script on the sharpoint server. You may have to modify the strURL variable.
  • The path to STSADM varies by locale.

    '** Begin Copy here
    '******************* SPSBK.VBS ****************************************
    '** Save this file with a .vbs extension
    '**
    '** Share Point Services Backup
    '** This script is meant to be run periodically to create a backup of
    '** a sharepoint site to a local folder.
    '**
    '** This script runs stsadm with the parameters needed
    '** to create a full backup named after the date.
    '**********************************************************************


    'Create the Variables
    dim strCmdPath ' Used to store the path where stsadm is located
    dim strBKPath ' Used to store the path where backup files will be stored
    dim strFileDate ' Used to store the date which is appended to the file name.
    dim strCmd ' Used to hold the entire command sent to the shell.
    dim strURL ' Used to store the URL for the Sharepoint Backup


    '************************************************************************
    ' Here is where the location is set. Change these depending on Machine **
    '************************************************************************
    ' This is the path where stsadm is
    strCmdPath = "c:\Program Files\Common Files\Microsoft Shared\" & _

    "web server extensions\60\bin\"

    ' This is the path where backup files will be stored
    strBKPath = "d:\SharepointBackups\"

    strURL = "http://localhost/sites"

    '************************************************************************
    ' Assemble the date string for the filename
    strFileDate = year(now) & "-" & month(now) & "-" & day(now)

    ' Build the command line.
    strCmd = chr(34)& strCmdPath & "stsadm.exe " & chr(34) & "-o backup -url " & _
    strURL & " -filename " & strBKPath & strFileDate & "-SharepointBackup.dat"

    ' Execute the command.
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run(strCmd)
    '*** End Copy Here


    A Good SharePoint Blog:

    Penny on SharePoint - Penny Coventry MVP's SharePoint blog.


Thursday, October 19, 2006

The Outlook Dumpster - Adventures in Deleted Item Recovery

If you are a Outlook user (on a Microsoft Exchange server) and don't know about the Outlook Dumpster, whoa Nelly are you going to be glad that you read this post.

If you manage an Exchange server, and don't know about the Dumpster, then you may want to mark this day on your calendar, so that you can celebrate it in the years to come.

As many of you know, when something is deleted from Outlook, it goes into the handy dandy Deleted Items Folder, but what many users don't know is that even after you empty the deleted items folder, the data still hangs around for awhile. How long depends on what your exchange administrator has decided. This is specified in the Mailbox and Public folder limit policies on the exchange server. Personally, I keep everything for 120 Days.


Recovering Items from an emptied Deleted Items Folder

So you are a good user, and you regularly empty your Deleted Items Folder, when suddenly you realized that you accidentally deleted your favorite Kim Chee recipe, and it was the only copy you had. All you have to do to recover it is:


  1. Highlight the Deleted Items Folder
  2. Click on Tools Recover Deleted Items
  3. Look through the list, and find that Kim Chee recipe, then highlight it.
  4. Click on the "Recover Deleted Items" icon (it looks like an envelope with an arrow on it).
  5. Go back to your deleted Items folder, and there it is.
  6. Make the Kim Chee , eat it a week or two later, and apologize to your co-workers for the smell.

Sounds good, nothing can go wrong right?

It does sound pretty good, but there are some instances when items don't go into the deleted items bin, this is referred to as "Hard Deleting" an item. There are several ways that this may happen. If you use shift + Delete when deleting an item, or if you move an item from a folder to either a personal folder file or to another mailbox. If this happens, then you can not recover them using the above method, because the "recover delete items" option is not available.

Well, that isn't so great.

Don't fear though, you can use a simple registry change to make the option available everywhere. Just follow the below instructions, but be careful, editing your registry can have some really bad results if you do it wrong.


  1. Close Outlook (and all of the outlook windows).
  2. regedit
  3. Go to HKEY_LOCAL_MACHINESOFTWAREMicrosoftExchangeClientOptions
  4. Right click on the right side of the screen, and choose New DWORD Value.
  5. Type in “DumpsterAlwaysOn”
  6. Double Click the value and enter 1 into the Value Data, then click on OK.
  7. Open outlook again.


If you want to read the steps for this all on your own, as well as Microsoft's Official "bad stuff can happen when you edit the registry" spiel, then just follow the link to the Microsoft Knowledge Base article and see for yourself (see if I care).


So what do I care, I'm an Exchange Administrator?


I'm pretty sure that no one would actually ask this question. This is a must have registry change for a Exchange Admin, but more importantly though, is that you set up your Exchange Server to maintain deleted items for some reasonable period of time. This way when your CEO syncs their new handheld, and it hard deletes all of their calendar, contacts and task information, you can swoop in and fix it in a few minutes. Of course the alternative is to load up some backup tapes (you have those right?), and restore the data, and hope that the CEO didn't make a whole slew of changes since your last backup. This is also handy when someone accidentally deletes all of the items from a public folder, and you don't find out until a month later after the fact. Of course, we need that information now.



Here is an excellent article about How to Implement System Policies in Exchange 2003 , and it also covers the Deleted Items retention policy.



Thursday, January 05, 2006

Strange SharePoint Team Services 2 Restore Issue

Like a good administrator, I was testing my SharePoint site backups, and was having a devil of a time getting it to work. Before I go into too much detail, if you are not familiar with backing up and restoring SharePoint using the stsadm command line tool, then you probably don’t want to read any farther.

If you are reading this, than you probably already know how to use it, or have looked at this Command Line Operations guide to stsadm.

To continue, I was testing the restore of my backup, and kept running into an error "Exception from HRESULT: 0x80040E2F”. I tried the usual, creating a site, and then deleting it, and verifying the versions, all to no avail. Of course I have gobs of free time, watch out for the puddle of sarcasm over there, so it wasn’t too big of a deal.

I had tested the backup and restore very thoroughly when I set up my neat little script, which backs up the entire SharePoint site every night, with the convenient file name of year-month-day-sharepointbackup.dat. As it turns out, what I was doing was renaming the backup file to sprestore.dat so that I didn’t have to do all that typing when I tried the restore. Once I stopped renaming the backup file, it worked like a charm.

Oh well, we live and we learn.

PS: If you have any interest in the script, reply to this post, and I’ll be sure to clean it up a little, and post it.

You may also like:
- Tools to work with SharePoint Offline – Review of Revelation and Colligo for SharePoint
- Script to Back up SharePoint Team Services 2