Compartilhar via


Fixing Broken Links after Restoring a Sharepoint (WSS) Site with SMigrate

Utility and source code here  (https://www.addysanto.com/blog/fixsitelinks.zip)

Introduction

 

WSS 2.0 includes a utility called SMigrate which can be used to backup the content and structure of a site and to later recreate a site’s content and structure from the backup file. SMigrate also enables migration scenarios – by backing up a site and restoring it to a different URL, it is possible to migrate content between different sites or servers.

 

When restoring content to a different URL SMigrate attempts to update the necessary links to ensure that the restored site will work correctly, including the Detail and Help links of webparts.  In most cases, SMigrate will accurately update all of the webparts.

 

When using Frontpage (or other dev tools which circumvent the WSS UI) it is possible to create custom pages and webparts which will not be correctly updated by SMigrate when a site is restored.  One possible solution is to manually update the broken links through the “Webpart Properties” page of the WSS UI , but manual corrections aren’t feasible for large sites or automated/scripted deployment scenarios.

 

FixSiteLinks is a utility which can fix such sites.  When run, it scans webparts in ASPX pages in the site (in the root and all subdirectories) and attempts to correct any URLs which point to links outside the site.

 

Usage

 

FixSiteLinks accepts the following command line parameters:

 

-site URL

The site parameter specifies the base URL of the WSS site to scan.

 

-update (Optional parameter)

The update parameter causes FixSiteLinks to update any webpart links which point outside the scope of the current site (as defined by the “site” parameter).  FixSiteLinks will not make any changes to the site if the –update parameter is not present.

 

The FixSiteLinks utility logs the results of each run into a file named FIXSITELINKS.OUTPUT.XML.  This file documents the following information:

- Site Folders

o ASPX Pages in each Folder

§ Web Parts on each Page

· The original Detail Link of the webpart

· The suggested Detail Link of the webpart

· Action taken.  Possible values are :

o Updated  (if changes were made)

o Skipped (if –update wasn’t specified)

o None (if existing link is valid)

The output file is always created (regardless of the –update parameter) and is overwritten with each run. 

 

I highly recommend first running the utility without the –update parameter and using the output file verify that the suggested changes make sense.  If you are satisfied with the suggested changes then re-run the utility with the –update parameter to apply the changes.  In the initial version there is no option for changing the default suggestions– if you don’t like them, don’t apply the changes via the –update parameter.

 

 

Notes

- This utility must be run on the server hosting WSS

 

- This utility requires administrative rights.

- ONLY RUN THIS IF YOU HAVE AN UP-TO-DATE SITE BACKUP.  This hasn't caused any damage to my systems (yet?) but incorrect usage could easily corrupt your site so : Use this at your own risk!

- Don’t use the –update parameter before reviewing the suggested changes.

 

- Source code is included, feel free to modify as needed.

- “Nice to Haves” which didn’t make the cut in the initial version:

o More intelligent algorithm for correcting links

o Fine-grained control of which pages/webparts to update

 

Disclaimer

I DO NOT MAKE ANY CLAIM OF WARRANTY, EXPRESS OR IMPLIED, INCLUDING THE FITNESS FOR ANY PARTICULAR PURPOSE, OR ASSUME ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF THIS TOOL, NOR WILL I BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING BUT NOT LIMITED TO DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, OR DAMAGES FOR BUSINESS INTERRUPTION OR LOSS OF BUSINESS PROFITS OR DATA, RESULTING FROM USAGE OF THIS TOOL OR RELATED INFORMATION PRESENTED IN THIS POST.

Also: the entire physical universe, including the information provided herein, may one day collapse back into an infinitesimally small space. Should another universe or medieval re-enactment subsequently re-emerge, the existence of the this tool (and it’s proper functioning) in this universe cannot be guaranteed. YMMV.

Comments