Feed Icon  


  • Bryant Likes
  • Send mail to the author(s) E-mail
  • twitter
  • View Bryant Likes's profile on LinkedIn
  • del.icio.us
Get Microsoft Silverlight
by clicking "Install Microsoft Silverlight" you accept the
Silverlight license agreement

Hosting By

Hot Topics


Open Source Projects



Backing up SharePoint

Posted in SharePoint at Wednesday, February 9, 2005 7:10 AM Pacific Standard Time

I looked into backing up SharePoint awhile back and didn't come away with a good solution. Recently MSDN published a new articled on How to Write a Back Up and Restore Application for SharePoint Portal Server 2003. The first time I looked at the article I skimmed it and didn't find it very useful and wrote it off. However, Brian E. Cooper blogged that it was Worth a Read!

So I went back and downloaded the sample and went though the article and I must admit, it was worth a read. There were several things I did like and some that I did not.

First, I liked the fact that I was able to do a full backup and restore of a SharePoint Portal. I built a Portal on a Virtual Server, backed it up, messed it up, and then restored it. It worked pretty well. Everything was restored except for the WebPart packages. For some reason I had to uninstall/reinstall my web part packages to get them to work. However, this isn't too much of an issue. The main thing was that the content and structure was restored successfully.

Second, the application that comes with the article is a sample application (as referenced by the application name SPSBackupSample). So, what is a SharePoint junkie to do with a sample application except to create a full blown application. I spent much of the day yesterday building my own version of the application written in C#. Everything was going well until I hit the section that backs up the indexes using the CSPSBackupClass. This class is used to backup the indexes to a stream using a method BackupToStream.

In the sample application (which is written in C++) you pass in an IStream pointer. In C# you should be able to do this (if I understand things correctly) by passing the pointer to a UCOMIStream object (using Marshal.GetIUnknownForObject). However, it doesn't seem to matter what I do, I get an exception from the CSPSBackupClass object. So I'm stuck at this point.

I could use the BackupToFile option but I was hoping to keep my sample compatible with the original sample. Any ideas?

Update: In case anyone is interested, here is the exception details that I'm getting:

System.UnauthorizedAccessException: Access is denied.
   at mssctlbm.CSPSBackupClass.BackupToStream(String bstrHostName, Object pStream, String bstrPassword, String bstrSite)
   at BackupSPS.BackupSite.Backup(String location, String backupName)

Update: Ok I was able to get this to work. I ended up writing a C++ console application that calls my C# class library. The problem was that I needed to make these two calls when my program started up:

    HRESULT hr = CoInitializeSecurity(NULL, -1, NULL, NULL, 

According to PInvoke.net you shouldn't call CoInitializeSecurity from managed code:

That's because the CLR will almost always call CoInitialize upon startup before execution enters your main method, and CoInitialize will implicitly call CoInitializeSecurity if it hasn't already been called.  Therefore, calling this from managed code will usually return RPC_E_TOO_LATE.

Once I switched to using a C++ app that called my class library everything started working. Once I get this completed I will probably post it up to a new project on source forge in case anyone is interested.

Thursday, February 10, 2005 10:52:00 PM (Pacific Standard Time, UTC-08:00)
I would be *very* interested. I am pleased that MS have provided the original article but disappointed that they haven't gone the whole way and produced a complete tool that can be used on production systems.
<br>I look forward to seeing your results.
Philip Colmer
Friday, February 11, 2005 11:56:00 AM (Pacific Standard Time, UTC-08:00)
Wow, this is great. I would be very interested!
Saturday, September 24, 2005 3:43:00 AM (Pacific Daylight Time, UTC-07:00)
Is it just me?
<br>I was trying my hand at Sharepoint development in C++ using the SPSBackupSample when I noticed that there are more properties and methods exposed to the C++ interface in VS2003 from Sharepoint.Portal.dll than there are when using C#. We're told that Portal is developed in C#, most developers use C# or VB, yet in C++ there are hidden properties and methods that appear to be useful to developers that don't appear to be flagged private or protected in C++ that you can't access in C# or VB. In fact there are many more, most of these "extras" are not even listed in the Sharepoint SDK documentation. Try it for yourself and see, create a C++ project and reference the Sharepoint.Portal.dll and use the namespace from it. I was working with the TopologyManager object when I noticed this.
<br>I have to ask, whats up with that!!??
Wednesday, February 7, 2007 7:35:51 PM (Pacific Standard Time, UTC-08:00)
Exception in BackupApplication: Source=mssctlbm, Message=The server threw an exception.
Wednesday, August 22, 2007 4:28:30 PM (Pacific Daylight Time, UTC-07:00)
I'm trying to backup SPS the same way as mentioned in the MS article , However while doing the backuo of search server I call

BackupToStream () method, this call throws an exptn System.Runtime.InteropServices.COMException returing an HRESULT(0x80040D61) , Is it because of something happeing in the mssctlbm.dll ? can you share your views ?

2) Brian E. Cooper blogged that it was Worth a Read!
This link seems to be broken ,it would be great if you have a copy somehwere shared ?

Friday, November 28, 2008 3:40:50 AM (Pacific Standard Time, UTC-08:00)
do you have the spsbackupsample code in c#?
Comments are closed.