stsadm, Site Collection Restore, and the “File Not Found” error

Restoring site collections with stsadm is normally a straightforward affair, requiring little to no manual intervention to get things back up and running. That is of course, unless you are restoring sites based on the Publishing Site template.

I recently wanted to take an existing site collection, make a copy of it in the same web application under a newly created managed path and have it reside in a new content database. The backup went smooth, utilizing stsadm -o backup. The creation of the new managed path went off without a hitch. The creation of a new content database and the restoration of the site collection into that database also occurred with no issues.

Browsing the site however told a different story. I was immediately greeted with a standard error page stating “File Not Found”. Browsing to other pages within the site (eg. “/_layouts/settings.aspx“) yielded the same result. After turning on the callstack/debugging and disabling the custom error page, I was greeted with the following:

File No Found Error

The problem? Each publishing page points to an incorrect page layout after the restoration. One would think that the restore via stsadm would recognize this and fix it, but it does not.

The fix? The stsadm extensions published by Gary Lapointe. The package built by Gary offers a command call gl-fixpublishingpagespagelayouturl. Verbose? Yes. Does it work? Absolutely.

After running the command and executing an iisreset, the site was once again able to be browsed and appears to be intact.

Reference

Migrating a Content database from a RTM farm to a SP1 farm in SharePoint

Recently, we came across a need to migrate an existing (SharePoint 2007) RTM content database to a new farm, which had SP1 pre-installed.  After taking a full backup of the existing database (through SQL Server), the backup was restored in the new farm.

Note: I should also mention that the database was migrating from SQL Server 2000 to SQL Server 2005.

After resetting the SharePoint servers, browsing to the site in question brought the following error:

Server error: http://go.microsoft.com/fwlink?LinkID=96177

At this point, we detached the content database in question (Central Administration » Application Management » Content databases). Once the database was successfully detached from the farm, it was reattached using the following STSADM command:

stsadm -o addcontentdb -url ‹URL› -databasename ‹DBNAME›

Reattaching the content database with the above command completely successfully, and as an added benefit performed an inplace upgrade, bringing the database schema up to SP1.  This might prove to be a helping hand when it comes to migrating to MOSS 2007 SP1 if your wish is to start with a new farm, but retain your original content.

Performance Optimization WordPress Plugins by W3 EDGE