次の方法で共有


Moving databases between web apps

There's quite a list of tasks to complete if you want to move databases between web apps with different url’s. Knowing this, see if an Alternate Access Mapping (AAM) will work for you instead of moving databases between web apps.

 Here's a list of things to be mindful: Note: this is not meant to be all inclusive.. just a list of things we thought were important.

  •  Before detaching your MOSS databases, make sure to run stsadm -o preparetomove. This will ensure your SSP data is consistent after the move. See the following article for more information: https://technet2.microsoft.com/Office/en-us/library/279e8dc2-a9a9-47e5-b17c-3a00af4878de1033.mspx
  • If attaching content across farms keep in mind that SharePoint may need to "upgrade" your databases. This doesn't take too long, but should be accounted for.
  • You may lose customizations/personalization’s if your custom web parts are not deployed to the receiving web app or globally. Review your log to ensure everything is healthy during and after the attach. The log is located at %programfiles%\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS by default.
  • If you are replacing one web app with another, make sure to sync your settings/templates/etc between the two web apps before attaching to the receiving web app.
  • Make sure the new web apps url (or relevant wildcard) is in IE's trusted or local intranet zone before rolling out to your users to prevent authentication prompts.
  • You will need to fix user alerts after the move if your url changed. There was some code released to address this in support article located here: https://support.microsoft.com/default.aspx?scid=kb;en-us;936759 While this will ensure the alerts work after the move, it doesn't actually update the contents of the alert which also contains a link to... you guessed it, the original url. My colleague Sean Kelley created a tool to fix this problem. I'll see if I can get him to post the code as I'm interested in seeing how this was done myself. (The OM doesn't seem to have any methods to update the embedded url.) (Update: Sean happen to be creating a blog as I was writing this and did post his code. You can find it here: https://blogs.msdn.com/skelley/archive/2007/06/18/alerts.aspx
  • If you’re my site host or record center host is changing make sure to update those properties as well.
  • There are likely to be many hardcoded url's that refer to the url of the old web app. You can leave it up to your users to update these links or better update these yourself. I think one of my other colleagues has a linkfixer app to address this. I'll track it down and see if I can get it posted.
  • As soon as your web app is moved and links are updated, make sure to kick off a full crawl (assuming MOSS) so that search results are updated. Allow yourself time for this step if search is important to your organization. The time required will vary depending on many factors beyond the scope of this article.
  • Finally, if your sites happened to be linked to a "portal" you will need to update this connection if the url or description of the "portal" changed. Here's some quick and dirty code I put together in a few minutes to fix this for our sites. If your web app doesn't have a top level site, make sure to update this code to reflect that.

 

<update: moved code to code snippet box>

 using System;
  
 using System.Collections.Generic;
  
 using System.Text;
  
 using Microsoft.SharePoint;
  
 using Microsoft.SharePoint.Administration;
  
 namespace MoveDBtoNewWebApp
  
 {
  
 class Program
  
 {
  
 static void Main(string[] args)
  
 {
  
 if (args.Length != 3) help();
  
 else
  
 {
  
 //SPSite site = new SPSite(args[0].Trim());
  
 string webappurl = args[0].Trim();
  
 string portalName = args[1].Trim();
  
 string portalurl = args[2].Trim();
  
 try
  
 {
  
 //Bind to the top-level site
  
 //TODO: will not work if no top level site exists but web application is present
  
 //How do you bind to a web application directly?
  
 SPSite toplevelsite = new SPSite(webappurl);
  
 if (toplevelsite != null)
  
 {
  
 //Bind to web application that hosts top-level site
  
 SPWebApplication spwebapp = toplevelsite.WebApplication;
  
 //Close top-level site
  
 toplevelsite.Dispose();
  
 //Enumerate through all sites in web application
  
 foreach (SPSite site in spwebapp.Sites)
  
 {
  
 try
  
 {
  
 //Set search center url for site collection
  
 //GetWebProperties(site, portalurl, portalName);
  
 SetWebProperties(site);
  
 }
  
 catch (Exception e)
  
 {
  
 Console.WriteLine(e.Message + " " + e.StackTrace);
  
 }
  
 finally
  
 {
  
 site.Dispose();
  
 }
  
 }
  
 }
  
 }
  
 catch (Exception e)
  
 {
  
 Console.WriteLine(e.Message + " " + e.StackTrace);
  
 }
  
 finally
  
 { 
  
  
  
 }
  
 }
  
 }
  
 public static void SetWebProperties(SPSite site, string url, string name)
  
 {
  
 if (site != null)
  
 {
  
 try
  
 {
  
 site.PortalUrl = url;
  
 site.PortalName = name;
  
  
  
 Console.WriteLine("site: " + site.Url + " was configured successfully");
  
 }
  
 catch (Exception e)
  
 {
  
 Console.WriteLine("error: " + site.Url + " " + e.Message);
  
 }
  
 finally
  
 {
  
 //Ensure SPSite object is disposed. 
  
 site.Dispose();
  
 }
  
 }
  
 else
  
 { 
  
 //site is an orphan. Report to user.
  
 Console.WriteLine("error " + site.Url + " is an orhpan.");
  
 }
  
 }
  
 public static void help()
  
 {
  
 //Help not very verbose. This will be used once and possibly integrated with STSADM.
  
 Console.WriteLine("");
  
 Console.WriteLine("SPMapPortal2.exe is used to connect all sites under a web application to the specified portal");
  
 Console.WriteLine("");
  
 Console.WriteLine("");
  
 Console.WriteLine("Usage");
  
 Console.WriteLine("SPMapPortal2.exe <web app url> <portal description> <relative url to portal>");
  
 Console.WriteLine("Example");
  
 Console.WriteLine("SPMapPortal2.exe https://contoso.com \"portal description\" / ");
  
 }
  
 }
  
 }
  

Comments

  • Anonymous
    June 18, 2007
    this past weekend we had a sharepoint farm where we needed to detach the databases and reattach them

  • Anonymous
    July 17, 2008
    Were you able to recover the 'linkfixer app' from your friend? Thanks