Do you trust TechNet? I generally do, as I figure the good folks at Microsoft are doing their best to disseminate reliable information to those of us working with their products. As I recently learned, though, even the information that appears on TechNet needs some cross-checking once in a while.
Bear with me, as this post is equal parts narrative and data discussion. If you don’t like stories and want to cut straight to the chase, though, simply scroll down to the section titled “The Conclusion” for the key takeaway.
Site Collection Backup Primer
For those who aren’t overly familiar with site collection backups, it’s probably worth spending a moment discussing them a bit before going any further. Site collection backups are, after all, at the heart of this blog post.
What is a site collection backup? It is basically what you would expect from its name: a backup of a specific SharePoint site collection. These backups can be used to restore or overwrite a site collection if it becomes lost or corrupt, and they can also be used to copy site collections from one web application (or farm) to another.
Anytime you execute one of the following operations, you’re performing a site collection backup:
- from the command line: STSADM.exe –o backup –url <url> –filename <filename>
- through PowerShell in SharePoint 2010: Backup-SPSite <url> –Path <filepath>
- Using the “Perform a site collection backup” link in SharePoint 2010 Central Administration
When a site collection backup is executed, a single file with a .bak extension is generated that contains the entire contents of the site collection targeted. This file can be freely copied and moved around as needed. Aside from some recommendations regarding the maximum size of the site collection captured using this approach (15GB and under in SharePoint 2007, 85GB and under in SharePoint 2010), the backups themselves are really quite handy for both protection and site collection migration operations.
A Little Background
John Ferringer and I have been plugging away at the SharePoint 2010 Disaster Recovery Guide for quite some time. As you might imagine, the writing process involves a lot of research, hands-on experimentation, and fact-checking. This is especially true for a book that’s being written about a platform (SharePoint 2010) that is basically brand new in the marketplace.
While researching backup-related changes for the book, I made a special mental note of the following change regarding site collection backups in SharePoint 2010:
The text that is circled in the image above (taken straight from a TechNet page titled Backup and recovery overview (SharePoint Server 2010)) says this:
Workflows are not included in site collection backups
This stuck with me when I read it, because I hadn’t recalled any such statement being made with regard to site collection backups in SharePoint 2007. Since Microsoft made a special note of pointing out this limitation for SharePoint 2010, though, I figured it was important to keep in mind. Knowing that workflows had changed from 2007 to 2010, I reasoned that the new limitation was probably due to some internal workflow plumbing alterations that adversely affected the backup process.
A couple of weeks back, I was presenting at SharePoint Saturday Ozarks alongside an awesome array of other folks (including Joel Oleson) from the SharePoint community. Due to a speaker no-show in an early afternoon slot, Mark Rackley (the event’s one-man force-of-nature organizer) decided to hold an “ask the experts” panel where attendees could pitch questions at those of us who were willing to share what we knew.
A number of good questions came our way, and we all did our best to supply our experiences and usable advice. Though I don’t recall the specific question that was asked in one particular case, I do remember advising someone to perform a site collection backup before attempting to do whatever it was they wanted to do. After sharing that advice, though, things got a little sketchy. The following captures the essence of the exchange that took place between Joel and me:
Me: <to the attendee> Site collection backups don’t capture everything in SharePoint 2010, though, so be careful.
Joel: No, site collection backups are full-fidelity.
Me: TechNet specifically indicates that workflows aren’t covered in site collection backups with SharePoint 2010.
Joel: No, the backups are still full fidelity.
Me: <blank stare>
The discussion topic and associated questions for the panel quickly changed, but my brain was still stripping a few gears trying to reconcile what I’d read on TechNet with what Joel was saying.
After the session, I forwarded the TechNet link I had quoted to Joel and asked if he happened to have an “inside track” or perhaps some information I didn’t have access to. We talked about the issue for a while at the hotel a little later on, but the only thing that we could really conclude was that more research was needed to see if site collection backups had in fact changed with SharePoint 2010. Before taking off that weekend, we decided to stay in contact and work together to get some answers.
Under The Hood
To understand why this issue bothered me so much, remember that I’m basically in the middle of co-authoring a book on the topic of disaster recovery – a topic that is intimately linked to backup and restore operations. The last thing I would ever want to do is write a book that contains ambiguous or (worse) flat-out wrong information about the book’s central topic.
To get to the heart of the matter, I decided to start where most developers would: with the SharePoint object model. In both SharePoint 2007 and SharePoint 2010, the object model types that are used to backup and export content typically fall into one of two general categories:
- Catastrophic Backup and Restore API. These types are located in the Microsoft.SharePoint.Administration.Backup namespace, and they provide SharePoint’s full-fidelity backup and restore functions. Backup and restore operations take place on content components such as content databases, service applications, and the entire SharePoint farm. Catastrophic backup and restore operations are full-fidelity, meaning that no data is lost or selectively ignored during a backup and subsequent restore. By default, catastrophic backup and restore operation don’t get any more granular than a content database. If you want to protect something within a content database, such as a site collection, sub-site, or list, you have to backup the entire content database containing the target object(s).
- Content Deployment API. The member types of this API (also known internally at Microsoft as the PRIME API) reside within the Microsoft.SharePoint.Deployment namespace and are used for granular content export and import operations. The exports that are created by the types in this namespace target objects from the site collection level all the way down to the field level – typically webs, lists, list items, etc. Content Deployment exports are not full-fidelity and are commonly used for moving content around more than they are for actual backup and restore operations.
So, where does this leave site collection backups? In truth, site collection backups don’t fit into either of these categories. They are a somewhat unusual case, both in SharePoint 2007 and SharePoint 2010.
Whether a site collection backup is initiated through STSADM, PowerShell, or Central Administration, a single method is called on the SPSiteCollection type which resides in the Microsoft.SharePoint.Administration namespace. This is basically the signature of the method:
SPSiteCollection.Backup(string strSiteUrl, string strFilename, bool bOverwrite)
To carry out a site collection backup, all that is needed is the URL of the site collection, the filename that will be used for the resultant backup file, and a TRUE or FALSE to indicate whether an overwrite should occur if the selected file already exists.
If you were to pop open Reflector and drill into the Backup method on the SPSiteCollection type, you wouldn’t get very far before running into a wall at the SPRequest type. SPRequest is a managed wrapper around the take-off point for a whole host of external calls, and the execution of the Backup method is actually handled in unmanaged legacy code. Examining the internals of what actually takes place during a site collection backup (or restore, for that matter) simply isn’t possible with Reflector.
Since the internals of the Backup method weren’t available for reflective analysis, I was forced to drop back and punt in order to determine how site collection backups and workflow interacted within SharePoint 2010.
I knew that I was going to have to execute backup and restore tests at some point; I was just hoping that I would be a bit more informed (through object model inspection) about where I needed to focus my efforts. Without any visibility into the internals of the site collection backup process, though, I didn’t really have much to start with.
Going into the testing process, I knew that I wasn’t going to have enough time to perform exhaustive testing for every scenario, execution path, variable, and edge-case that could be relevant to the backup and restore processes. I had to develop a testing strategy that would hit the likely problem areas as quickly (and with as few runs) as possible.
After some thought, I decided that these points were important facets to consider and account for while testing:
- Workflow Types. Testing the most common workflow types was important. I knew that I would need to test at least one out of the box (OOTB) workflow type. I also decided that I needed to test at least one instance of each type of workflow that could be created through SharePoint Designer (SPD) 2010; that meant testing a list-bound workflow, a site collection workflow, and a reusable workflow. I decided that custom code workflows, such as those that might be created through Visual Studio, were outside the scope of my testing.
- Workflow Data. In order to test the impact of backup and restore operations on a workflow, I obviously had to ensure that one or more workflows were in-place within the site collection targeted for backup. Having a workflow attached to a list would obviously test the static data portions of the workflow, but there was other workflow-related data that had to be considered. In particular, I decided that the testing of both workflow history information and in-process workflow state were important. More on the workflow state in a bit …
- Backup and Restore Isolation. While testing, it would be important to ensure that backup operations and restore operations impacted one another (or rather, had the potential to impact one another) as little as possible. Though backups and restores occurred within the same virtual farm, I isolated them to the extent that I could. Backups were performed in one web application, and restores were performed in a separate web application. I even placed each web application in its own (IIS) application pool – just to be sure. I also established a single VM snapshot starting point; after each backup and restore test, I rolled back to the snapshot point to ensure that nothing remained in the farm (or VM, for that matter) that was tied to the previous round of testing.
I created a single Publishing Portal, bolted a couple of sub-sites and Document Libraries into it, and used it as the target for my site collection backup operations. The Document Library that I used for workflow testing varied between tests; it was not held constant and did change according to the needs of each specific test.
I ran four different workflow test scenarios. My OOTB workflow scenario involved testing the page approval workflow for publishing pages. My other three SPD workflow tests (list-bound, site collection, and reusable workflow) all involved the same basic set of workflow steps:
- Wait five minutes
- Create a To Do item (which had to be completed to move on)
- Wait five more minutes
- Add a comment to the workflow target
In both the OOTB workflow and SPD workflow scenarios, I wanted to perform backups while workflows were basically “in flight” to see how workflow state would or wouldn’t be impacted by the backup and restore processes. For the publishing approval workflow, this meant taking a site collection backup while at least one page was pending approval. For the SPD workflows, it meant capturing a backup while at least one workflow instance was in a five minute wait period and another was waiting on the completion of the To Do item.
Prior to executing a backup in each test case, I ran a couple of workflow instances from start to finish. This ensured that I had some workflow history information to capture and restore.
Once site collection backups were captured in each test case, I restored them into the empty web application. I then opened the restored site collection to determine what did and didn’t get transcribed through the backup and restore process.
Results Of Testing
In each workflow case (OOTB and all three SPD workflows), all workflow information that I could poke and prod appeared to survive the backup and restore process without issue. Workflow definition data was preserved, and workflow history came over intact. Even more impressive, though, was the fact that in-process workflow state was preserved. SPD workflow steps that were in the middle of a wait period when a backup was taken completed their wait period after restore and moved on. To Do items that were waiting for user intervention continued to wait and then proceeded to the next step when they were marked as completed in the restored site collection.
In addition, new instances of each workflow type could be created and started in both site collections following the backup and restore operations. The backup and subsequent restore didn’t appear to have any effect on either the source or destination.
Though my testing wasn’t exhaustive, it did cast a doubt on the absolute nature of the statement made on TechNet regarding site collection backups failing to include workflows.
While I was conducting my research and testing, Joel was leveraging his network of contacts and asking folks at Microsoft for the real story behind site collection backups and workflow. He made a little progress with each person he spoke to, and in the end, he managed to get someone to go on the record.
The official word from Microsoft is that the TechNet note indicating that site collection backups don’t include workflows is a misprint. In reality, the point that should have been conveyed through TechNet was that content exports (via the Content Deployment API) don’t include workflows – a point that is perfectly understandable considering that the Content Deployment API doesn’t export or import with full-fidelity. Microsoft indicated that they’ll be correcting the error, and TechNet may have been corrected by the time you read this.
My takeaway on this: if something on TechNet (or anywhere else on the web) doesn’t quite add up, it never hurts to test and seek additional information from others in the community who are knowledgeable on the subject matter. In this case, it made a huge difference.