Friday, November 23, 2012

Rename a Site Collection

Occasionally users want their Site Collection renamed and the URL updated. It's a very reasonable request and pretty simple if we were dealing with a non-SharePoint website.  Since we can't rename a site collection through the UI we have to get a little more creative.

The Problem:
  • Need to change the name of the Site Collection
  • Need the URL to update with the name change
  • No renaming option in Central Administration
  • No renaming option in Manage Content and Structure
This isn't a single step process, but overall the process is pretty simple.   

  • Access to Central Administration
  • Destination Path to Export the Site Collection as a .CMP File
  • Name of Current Site Collection
  • Name of New Site Collection
  • Users who decide on a site name and then change their mind
The reason why we have to Export the Site Collection is so there won't be duplicate GUID's for what is actually a different Site Collections.  You can't have 2 Site Collections with the same ID's in 1 Farm, as it would *literally rip a hole in the space/time continuum.
The Solution:
We'll be Exporting the current Site Collection to a File and then restoring it under a different name.
  1. Open Central Administration
  2. Select Backup and Restore
  3. Granular Backup > Export a Site or List
  4. Under Site Collection, Select the Site Collection to Export
    • No reason to select site or list since we're exporting the entire site collection
    • example http://intranet/sites/old_and_broke
  5. File Location > Path + File name for the Export:  C:\exports\old_and_broke.cmp
  6. Select Export Full Security, but it can be deceiving and the Full Security doesn't come over well
    • I recommend you verify the security after restoring, as this process will create new SharePoint Site groups
  7. Export All Versions
  8. Click Start Export 
After a few minutes, which will vary depending your server, size of the site collection and the SharePoint Gods, the export will be complete. 
Renaming and Restoring the Site Collection using PowerShell
**There is an extremely complicated PowerShell command that we'll use to restore the site collection and rename it at the same time.
 Restore-SPSite http://intranet/sites/new_hotness -Path C:\exports\old_and_broke.cmp -Force
-DatabaseServer IntranetDBServer -DatabaseName WSS_Content_Intranet 
This line of PowerShell will restore the site collection under a new URL and to a specific Content Database.
Option #2 for renaming and restoring
There is also a 2nd option for restoring, if you already have an existing site collection you want to overwrite. 
Prerequisite:  The new site site collection with the new name must already exist.
Import-SPWeb http://intranet/sites/new_hotness –Path C:\exports\old_and_broke.cmp 
This wonderful line restores the site collection over top of an existing site collection. 
Option #3 for renaming and restoring
You can create a site collection, based on a site template with PowerShell and then restore overtop of that.
New-SPWeb http://intranet/sites/new_hotness -Template "STS#0"
Import-SPWeb http://intranet/sites/new_hotness –Path C:\exports\old_and_broke.cmp 
*No actual evidence of space ripping or even time ripping.
**Not actually complicated or extreme.

No comments: