Andrew Connell [MVP MOSS]
1543 Posts |  42 Articles |  4748 Comments
.NET  |  MCMS  |  SharePoint  |  Office System
SharePoint Quick Links
Article Categories
Archives
Post Categories


Add to Technorati Favorites

When creating new content-centric Web sites using something like ASP.NET, developers usually follow a set lifecycle. I've been involved in my share of content-centric sites using tools like Microsoft Content Management Server 2002 and Office SharePoint Server 2007 Web Content Management. The process is pretty easy getting a site off the ground:

Figure AA

We first create a basic site with the core templates, just enough to enter some dummy content in. We need this for things like content rollups and the like. We then continue building out the site. Finally we reach a point where our site is created enough to where the content owners can start loading content into the site (or we migrate content from an existing site).

Ultimately we'll take the development codebase and deploy it to production and migrate all the content (or as many of us do, just deploy the development site to production).

The Challenge...

The next thing that comes up is when you want to keep doing development. We all would want to develop against the production system in order to work with real world content. With an ASP.NET 2.0 site, this isn't too hard as it usually means you are just backing up and restoring a SQL Server database.

However when you toss Office SharePoint Server 2007 into the mix, you quickly find this isn't the most intuitive task. I get a lot of questions about how you're supposed to do this. Suffice to say, where are a few ways to skin this cat, but I've got a way that works for me and is pretty simple. There are few manual tasks, but most of this could be scripted to automate it.

This article will explain how you can do this. I'll be using my company's site, www.CriticalPathTraining.com which is a Office SharePoint Server 2007 Web Content Management site as my sample in this process.

Overview of the Process

Before diving into the details, let's look at the high level steps.

Figure BB

First step is to get a copy of the site from production and restore it into development. Once that's complete, you then need to create the local development SharePoint site(s). With the site created, you need to deploy all your custom code and files to the development site, so development will not only have the same content, but same code as production. Next, you need to associate the restored production databases with the new development site. Finally, depending on your implementation, you need to do any last minute cleanup (I'll explain this more later).

Moving Databases

The biggest piece of this whole process is the goal of getting the production site restored into your development environment. To do this you need to get a copy of your content database from production and restore it into your development environment. Once that's done, after the sites are created and custom code redeployed, you'll associate it with the development site. I guess you could punt this step (restoring DBs) down a little bit when you deal with the content DBs later, but I like doing this up front so I don't have to jump between systems.

Backup Production Content Databases

Pretty straightforward here... just go backup the database using the standard SQL Server backup tools in SQL Server Management Studio.

Restore Production Content Databases in Development Environment

Next, take the backed up databases and restore them into your development environment.

With the database restored, now go and grant the following SQL users DBO rights to the restored database:

  • The account you use as your SQL Serve farm administrator
  • The account configured as the identity of the application pool that you'll use for the development site
  • The account configured as the search crawl account (if you're leveraging SharePoint search in your site)

For me I also have a FBA database for my site members so I had to restore that and grant the identity of the app pool the necessary rights into it.

Create Development Site

Now its time to create site that will host the restored site collection.

Setup DNS/Host Entries

Some like DNS entries, others like host entries and some don't mind port numbers in their domains. For development, I hate ports and go with the old tried and true HOSTS file. Open the c:\Windows\System32\drivers\etc\HOSTS file. For me, my site has two Web applications: one the world uses (that's anonymous) and one we use for authoring content (NTLM only). Here's what I put in my site (note the last bit on the domain... always like making it obvious they are the local dev site and not production):

127.0.0.1    private.criticalpathtraining.comdev
127.0.0.1    www.criticalpathtraining.comdev

Create Web Application(s)

Now venture into Central Administration and create the Web application(s). I first create the one that will be used for the authoring site using these settings:

Figure CC

The only other points to make here is to ensure you pick the right app pool (the one that uses the identity that you granted DBO rights to your restored content database) and the name of your database Central Admin will create. You don't need this content DB... in fact we'll delete it in a moment. I usually name this WSS_Content_Garbage.

When prompted, skip the step to create a new site collection. No need... we've already got one and it's very nice!

For me, I then create a 2nd Web app that extends this one that uses the other host name (www.*).

Deploy Custom Code and Files to Development

I'm sure you've got at least some custom code in your site. So before you go further, add all WSP's to the farm's solution store and deploy them to the new site. This will do all the web.config updates.

Didn't use WSP's? SHAME ON YOU! Here's yet another classic reason why you should have!

Associate Restored Production DB's with New Development Site(s)

Now where the magic happens... time to do the old switch-a-roo! You are first going to remove the content database from the Web application you created as the dev site and replace it with the one you restored from production:

  1. From Central Administration, select Application Management » Content Databases.
  2. Switch to the Web app you created for the dev site (private.criticalpathtraining.comdev for me).

    Figure DD

  3. Select the only content database in use and remove it from the Web app.
  4. Now select Add a content database and enter the name of the database you restored (WSS_Content_CriticalPathTraining in my case). Leave all options as the default.

If you get an error here, it's likely you didn't grant the necessary logins access. See the previous section above about restoring the database.

That's it! Your site is now restored in development!

Fix-up Site Collection Owner

Now I bet your production and development sites are in different domains. Mine are so I always need to change the site collection owner so I can get back in.

  1. From Central Administration, select Application Management » Site collection administrators.
  2. Switch to the site collection you created for the dev site (private.criticalpathtraining.comdev for me).
  3. Change the primary administrator to an account on your dev machine.

Additional Site-Specific Cleanup

At this point you're good to go. You might have some additional stuff you need to setup. For instance a custom FBA setup, like we use for site members, or configuration info with the BDC or links to other external systems.

Re-establishing FBA

We use standard the OOTB ASP.NET membership stuff and FBA for our public site for people to login and get protected content. When replicating the development environment, I need to do the following steps after everything above is complete:

  1. Restore the FBA database from a backup taken from production.
  2. Add the connection string, membership and role providers to the web.config files of both Web applications & Central Administration (with the extra little default role provider fixup).
  3. From within Central Administration, configure the Web application membership & role providers from within Central Administration.

Conclusion

That's it! At this point you should have a restored production site in development. You'll likely have a few permission issues popping up here and there... I find I need to disable anonymous access and re-establish it at times. Most issues can be rooted in the fact that content was created and managed by identities in a different AD than you're in down in your development environment. Nothing major... just a hassle.

posted on Thursday, July 23, 2009 10:55 AM

Feedback

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/23/2009 9:44 PM lcr
Gravatar Great and VERY timely article.

2 things:

1) when I use host headers on my server (in HYPER-V vm), I can not get past the user/pass challenge and yet when I got to another wfe or a client I can reach the app and it only happens when I use host headers and not ports.

2) can I use this transition method to migrate wss 2003 database to wss 3.0 servers?

Thanks again,

LCR.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/24/2009 6:25 AM AC [MVP MOSS]
Gravatar LCR-
Not sure what's giong on for you on point 1... I've heard some folks have issues with IE8 & loopbacks. Think there's a KB on it... just start searching. Sorry.

As for point 2, I think that does work... when the v2 DB is attached to a v3 environment, it upgrades the schema and content. But I think there's other stuff you have to address. Can't recall though...

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/25/2009 2:03 AM Michhes
Gravatar @LCR - most like the KB Andrew refers to: http://support.microsoft.com/kb/896861

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/25/2009 2:14 AM Michhes
Gravatar Andrew - As you say, there's more than one way to skin a cat: instead of dealing with the database backups, I regularly use

stsadm -o backup

and

stsadm -o restore

in prod and dev respectively. Are there any disadvantages to this approach over doing the backup at the SQL Server level? Slower, bigger, less reliable? On the reliability side, I've seen problems with stsadm backups not coming at the expected size and missing sites and other content or not restoring at all.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/26/2009 5:48 PM AC [MVP MOSS]
Gravatar Michhes-
I just prefer this method as backup/restore expects the URLs will not change. I've had other issues with backup/restore. When you move the content database, you can be assured you have *everything* except custom code & web.config changes (which is all addressed with deploying everythin via WSPs).

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/26/2009 10:58 PM Don Kirkham
Gravatar Great post, as I am just beginning to think about doing this. I do have one question: once you do this the first time, are the steps to do it again the same, or will just restoring the Content DBs do the trick? (I am thinking I will need to do this at regular intervals in order to sync with Content that has been added by the users; content that I anticipate having to develop against.)

Thanks again for the great information!

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/27/2009 6:35 AM AC [MVP MOSS]
Gravatar Don-
Personally I redo everything. I prefer to keep it as close to the same as production and doing it all together at one time is the best option (for me). Just create a snapshot in your virtual machine you are restoring to and rerun the scripts. Lots of this could even be scripted!

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/27/2009 9:50 AM John Way
Gravatar Great article. I have two questions.
1) We are migrating our MOSS front-end web server to a new server. Is there a problem with using this technique to setup the new server... This would mean that two front-end servers would be pointing at the same content databases. Once everything is setup, I would flip the DNS entry to point to the new server so that any content editing would only be performed from one server at a time.
2) Referring to your article, when I create the new web application (on the development server for example), I just use the name of the production content database that was copied to the dev sql server. This saves the creation and cleanup of the WSS_Content_Garbage database. Do you see any problems with doing it this way? I haven't run into any problems yet.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/27/2009 4:42 PM AC [MVP MOSS]
Gravatar John-
I know many folks who do it this way WRT your first question. Sometimes there are issues with URLs, but if I'm not mistaken Gary Lapointe has a custom STSADM command that helps with this. For #2, I've never tried that... prefer the remove/add method myself.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/28/2009 11:43 AM Craig
Gravatar In your article you say to Deploy Custom Code and Files to Development first then Associate Restored Production DB's with New Development Site(s).

Wouldn't it make more sense to Associate Restored Production DB's with New Development Site(s) first then Deploy Custom Code and Files to Development? I am just thinking of the case where your solutions deploy files into a document library. Thanks in advance for any help.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/28/2009 11:53 AM AC [MVP MOSS]
Gravatar Craig-
No... the way I have it is correct because those things you mention (solution deploy files into a doc lib) should already be there in production. Plus, not everyone writes their Features and custom components the right way where they check to see if it was run in the past and thus, shouldn't redo it (like programatically adding lookup fields to content types defined in a Feature).

You deploy the custom code soutions after creating the web apps (to update the web.configs). Then you associate the DB which will expect all the underpinnings (Features, files, etc... files on the file system) are there.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 7/30/2009 9:02 AM Simon
Gravatar Great Article - really interesting point on deploying the solutions first! I'm building up a new environment at the moment and that little gem would have saved me some time :)

Cheers

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 8/3/2009 4:41 PM Clint Simon
Gravatar Good post.

I am wondering how you proposed merging your development changes back into production?

Personally I prefer to use a custom export into a custom XML format, that way you can have portable content page that are not directly tied to a content database. This keeps your programming assets (layouts, master pages) separate of content.

Thoughts?

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 8/3/2009 10:45 PM AC [MVP MOSS]
Gravatar Clint-
I'm not much of a fan for exporting & importing content from dev to production so I don't have a process as I don't do it.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 8/12/2009 8:20 PM Clint Simon
Gravatar Sorry I was saying 2 different things. I think the main issue is that SharePoint does not differenciate programming assets such as master pages/page layouts from actual content. These are all in the content database therefore they move as one unit.

Given this, following your technique above, how would you then finish the cycle of deploying master page/page layout changes to production? This is not trivial in all cases because your master pages/page layouts can and often depend on the content itself for it's function.

I see this as a flaw in SharePoint when you are using a custom application development techniques to build a SharePoint site. In other products such as MS CRM there is a clearer delineation between programming assets and content. Essentially it boils down to keeping compatibility between your code elements, master pages/page layouts and content. The bummer is that MS has no story for this. It's not possible to model each of these elements cohesively in source control. #fail :)

So the underlying question is how do you maintain and enforce compatibility between master pages/page layouts and content when deploying from dev to production?

Separate from that, we often do migrate content from qa/uat to production because the content is a part of our deliverables. We model the content just as we model master pages and page layouts.


# re: Restoring Production MOSS 2007 Publishing Sites Into Development 8/13/2009 5:38 AM AC [MVP MOSS]
Gravatar Clint-
Now I see wher you're coming from. In my exp. this hasn't been an issue because I rarely have master pages/page layouts dependent on other content with the exception of rollups which take into account empty result sets. I'd rather recreate the content in each environment than move it around... but that's just me...

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 8/18/2009 3:31 AM Joakim Atterhall
Gravatar Hi! (this is a long one, sorry) I'm trying out to move one web application from one farm to a new one. Deployed all wsp's, setup the new web application and use backup/restore. No problems and I even used different accounts for most stuff in the different farms. The only things that were the same were the same domain, the same language and the same SP-level (SP2). Ok, the source used kerberos and the destination NTLM, which made in fail, but when corrected all is fine! Until...
Some links and stuff didn't show up. Hmmm... They use audience targeting and the audiences are defined in the shared services "admin" database (the orgle_list table), not its content database. So even if I'd make a backup/restore for the ssp, it won't work. And due to constraints in the db, you cannot create an audience with the same guid as in the source db.
What to do? Now I've created an stsadm command that exports and imports all audiences by creating new copies in the target. Then I have to parse and replace the audience guids in all items in all lists in all sites in all sitecollection in all web applications hosted by the ssp! Not a very fun thing, but it works.
Now comes the tricky part. I also need to update all webparts. Definitely not a very fun thing to do! To be lazy I first looked at editing the webparts in the database, but then I'd have to deserialize all properties in some way, but I quickly gave up that one.
Am I stupid or is there anyway to do this stuff correctly? I've been googling and what I've seen is that it isn't possible to migrate audiences.
Any help is most wanted!
Thanks in advance!

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 8/27/2009 9:23 AM Chris Roth
Gravatar We have a multi-environment setup using NTLM. Our Prod is on one domain and Test is in another domain. In order to refresh Test with Prod content the restored content still wants to reference the production domain. From CA we can associate site collection admins in the Test domain so we can access the content, but once in the site it just cannot seem to shake the desire to leverage the Prod domain.

We have the same account names in the Test domain. Is there a way to just tell it to use a different domain? I have dug around everywhere I could, even removing and reassociating the SSP in hopes that would trigger it. Any ideas?

# What Do you Mean "with the extra little default role provider fixup" 9/10/2009 3:07 PM DJ
Gravatar What does "with the extra little default role provider fixup" mean?

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 9/10/2009 3:12 PM Alan Nguyen
Gravatar Great article.

I have a couple of questions regarding backup/restore:

I have two dns entries

intranet and mysite pointing the same prod server that has a single IP using port 80

I use Central Administration to perform the farm backup, and everything went well.

Problem is when I restore the farm in mine dev environment.

I have the following dns entries in my development environment

intranetdev and mysitedev pointing to the dev server that has a single IP and both using port 80

I restored the farm in dev using central administration and repointing the host header from intranet to intranetdev and mysite to mysitedev.

mysite restored to mysitedev without any problem, but the restoration job fail when trying to restore intranet to intranetdev with the error saying that the port has been used by other IIS application. Please select other host header or port number.

Please note this backup / restore method works just fine if I use

intranet:80 and mysite:1100

And

intranetdev:80 with mysitedev:1100

How should I go about solving this problem?

Thanks,
Alan




# re: Restoring Production MOSS 2007 Publishing Sites Into Development 9/22/2009 6:39 PM Brad
Gravatar Intersting article. My knowledge of moving/copying a site was that a backup/restore was not the best way to go because their is information embedded in the site that references the original site: case in point we had an instance where this was done to copy a site collection and when a page was edited in a subsite with SPD, it would ask you wanted to edit the page layout (ok) in the orginal site collection, the one that was the source for the copy (not ok): and note, it would in fact open another SPD and the page layout in the orignal site on the other farm.

So what we found and were told is that the only way to move/copy a site should be either export/import or content deployment.

I'd be interested to here your feedback on this.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 9/23/2009 7:38 PM AC [MVP MOSS]
Gravatar Brad-
I only use this for doing development... I keep the same URLs in my local dev environment.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 10/7/2009 12:13 AM Chaitu
Gravatar Hi,

Can you pls elaborate the same in detail and if possible can you send the process in a Video format.

When i tried to implement the same i faced issues.Procedure followed is:
1)Took the back up from Prod and restored the same on Dev.
2)Created a webapplication using Central Admin Tool.
3)Took the back up of the Prod Site Collection using STSADM tool.
4)Restored the same on Dev using STSADM tool.
5)After that i have deleted the content database that gets created by default and mapped the DB restored from Prod to this.
6)Next i have made the connection string changes,safe controls entry in the Web.Config file.
7)After that i deployed the dlls to the bin of the Virtual directory created in WSS.

when i tried to access the dev Site i could not.

Please help me how to go about this as i need this dev site created at any cost.

Thanks in Advance.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 10/7/2009 6:45 AM AC [MVP MOSS]
Gravatar Chaitu-
You're adding some extra stuff in there. Don't backup the site collection... just backup & restore the conent database.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 3/12/2010 5:26 AM Basel
Gravatar I am in the satge of deploying what ever we has built and approved on test environment into production Env, environment is Medium farm (5 servers= 2XWFE + 1X AppServer + 2 SQL 2008 Mirroring)+ 1 server has AD & Exchange.
this Production environment running in isolated Area, as security laier that is recommened by Microsoft on technet the client as to use firewall in between 2XWFE and App Server,
beside that the WFE are running the application services so they are able to communicate directly to Backend SQL DB.
now i need to know what are all the prots required to be opened from WFE To APP Server & DB & AD for surving the request channels to those servers and gets back the outpout to the end user, before going LIVE witht the website.
I presume the ports are (80,143,ICMP,TCP) so anything else required.
thanks for help.

# re: Restoring Production MOSS 2007 Publishing Sites Into Development 3/12/2010 7:04 AM AC [MVP SharePoint]
Gravatar Basel-
Look to TechNet for this documentation.

Post Feedback

Title:
Name:
Email:
(email will not be displayed)
Url:
Comments: 
Please add 8 and 5 and type the answer here:    
All Comments Are Filtered & Moderated
Unfortunately comment spammers are just too effecient and are constantly dirtying up blogs with irrelevant and unwanted comments trying to improve their standing on search engines. All comments on this blog are moderated. I do not censor comments, but I don't approve comments with vulger language or those soliciting products. Most of the time comments are approved within a few hours of being submitted with the only exception when I'm traveling.

Why are you asking for my email address?
The only reason I'm asking for your email address, which isn't required to submit a comment, is to provide a gravatar if you've created an account for yourself and associated your email address with a small image. If you have a gravatar created for the email address you submit, it will appear next to your comment. Otherwise nothing will appear.

What is a gravatar?
A gravatar is a "globally recognized avatar." You can get more information about gravatars, as well as create your own for free, at www.gravatar.com. You can also view my gravatar here.


Copyright © 2003 - 2010 Andrew Connell
Creative Commons License 
This work is licensed under a Creative Commons License
Site design by Heather Solomon.

 
 
MOSS WCM Training
Looking for MOSS 2007 WCM developer training? Look no further! I teach my 5-day hands-on and online WCM classes for developers I offer through my company: Critical Path Training.

Get more information on the WCM courses!