*** UPDATE ***
I was made aware of a fix in SP1 that should cover this issue. http://support.microsoft.com/kb/941422
I have recently done a restore of a SharePoint farm without first creating the web applications as Microsoft suggests. (read previous post about web application timer jobs not created during a SharePoint restore). The issue was the problem wasn't found right away so Microsofts recommendation of running the restore again wasn't an option. I searched and searched for a solution that allowed me to manually fire up these timer jobs for these web applications, but nothing was found. Seemed like creating a new web application was the only option. Below are the steps that I took to resolve this issue for each web application involved (usually it would be every web app except for central administration).
Step 1: Backups and Preparation
Before starting any endeavor that can potentially hose up a web application and / or database it is recommended that the entire farm run a full backup just in case :). Next we will have to make sure we stop the IIS web sites so there are no additional changes being made to the databases as we are trying to move them. Do this by going into IIS and stopping the appropiate virtual servers running.
Step 2: Create a new Web Application
I created a new web application on a different port number and a temporary database name (WSS_Content_Port_DELETEME). I did so that I knew when finished which databases to delete. The temporary port number is there as a place holder until I could manually swap the ports with the "old" web application later.
Step 3: Prepare to move the Databases
There is a command that Microsoft has included with the new version of SharePoint called "PrepareToMove". This command is used as an operation under stsadm. This command allows the profile syncronization properties for the users for each site collection in the database to be disconnected, ultimately allowing the new web application to take over the role without causing errors in the syncronization process. You will have to run this command on every site collection in the database.
The first thing you would need to get is a list of site collections in the database. The command used to gather the list of site collections is "enumsites". The syntax for this can be found by running stsadm -help enumsites from the command prompt. What I typically do is output the results of that command to a text file so I can parse out the site collection URLs. I do this by running stsadm -o enumsites -url http://webapp >c:\sites.txt. Keep in mind that if you have more than one database on your web application, but you are only moving one of the databases, only the sites that are part of the database you are moving need to run the preparetomove operation.
When I have a list of the sites i need to move. I create a BAT file that will process all the sites using the preparetomove operation. What I do is create a command in the BAT file for each site collection I am preparing to move. The command looks like this: stsadm -o preparetomove -contentdb DBSERVER:DBNAME -site SITEURL. You will have to replace DBSERVER with the name of the database server the database is located, replace the DBNAME with the name of the database to move, and replace SITEURL with the url of the site collection in the database. Keep in mind that there must be a colon in between the DBSERVER and DBNAME values. Once I have the BAT file create I run it.
Step 4: Swapping Databases
Now that the sites have been identified and the preparetomove operation has been executed on the identified site collections. Now is the time to swap the databases to the web application we created in Step 1.
-
You do this by going into Central Administration and select "Application Management -> Content Databases"
-
Once in the content databases management area, select the "old" web application as the filter
-
Click on the database name(s) that the preparetomove operation was run against
-
Check the box to "Remove Database". You will get a warning saying that you are removing a database that contains sites and that nobody will be able to access the sites if the database is removed. Click "Ok"
-
Now you should be returned to the content database management area, select the "new" web application as a filter
-
Click on the temporary database that was created when the web application was created and remove the database by following steps above.
-
When the temporary database has been removed, attach the database from the "old" web application by clicking on the "Attach Database" link in the toolbar.
-
When attaching an existing database it is very important that the name entered for the database name is exactly the same as the database that exists in SQL that you are attaching
-
Once the name is entered in correctly, click ok and the database should be attached successfully.
Step 5: Swapping URL Addresses
This step we will have to swap the URL addresses in both SharePoint and IIS, since Microsoft did not build into the Alternate Access Mappings an automated feature that changes IIS for you... but I digress... :). Below are the steps to swap the URL addresses
-
Navigate to Central Administration and goto the Operations -> Alternate Access Mappings page.
-
Select the "old" web application AAM and change the url to another port that is not currently being used.
-
Select the "new" web application AAM and change the url to the port that the "old" web application was using.
-
Navigate to IIS Management
-
Right click on the "old" web application and select "Properties"
-
Change the port number to the port number you set for the "old" web application in the AAM area, click ok.
-
Right click on the "new" web application and select "Properties"
-
Change the port number to the port number you set for the "new" web application in the AAM area, click ok.
Now your new web application is running and users are able to access their content using the same URL as before, but now they are accessing the new web application. Repeat these steps for each web application that you need to recreate for the timer jobs to be present.
Step 6: Cleanup
This final step once everything has successfully be moved and tested is to remove all the "old" references in the system.
-
In Central Administration, navigate to Application Management -> Delete Web Application
-
Select the "old" web application to delete
-
Select "No" for each the remove database and remove IIS options. I recommend removing manually just in case SharePoint has some connection to the moved databases and application pools.
-
Go to the SQL Server and remove the temporary databases created called "DELETEME"
-
Go to the IIS Management area and remove the "old" IIS virtual servers that were used for the "old" web applications.
Now everything should be back to normal and all cleaned up. I hope that this will help someone resolve their issues and not have to go through the headache of figuring it out for yourselfs.