Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > Using Copy-SPSite to rename Site Collections in SharePoint 2013
October 09
Using Copy-SPSite to rename Site Collections in SharePoint 2013

As a SharePoint consultant I get asked all the time if there’s a way to rename (really repath) site collections. As SharePoint installations age, information architecture issues creep in. One of the ways this happens is that URL paths that were once correct no longer are. If the erroneous path is a web’s path, that’s easy enough to fix. You can use “stsadm –o renameweb” or Site Actions > Site Settings > Title, Description, and Logo. If you need to repath a site collection, well, that gets a little hairier. Okay, a lot hairier. There’s no way easy way to do it with out of the box tools. Before you say, “But, but, what about ‘stsadm –o rename’?” keep in mind that only works with hostname based site collections, and most site collections are path based. Yours are, I checked.

Since there’s no silver bullet we were reduced to workarounds. Normally that workaround looked like this:

  1. Backup site collection
  2. Delete site collection
  3. Restore site collection to new URL
  4. Pray, pray, pray

Not only was that process vulnerable to data loss from a bad backup or restore, it was very manual. As a general rule, I’m lazy and risk averse, so this process was bad for me.

I don’t know about you, but after the kids go to bed at night, I like to turn the lights down, pop some popcorn, put on some music, and cruise around in SharePoint 2013 looking for new PowerShell cmdlets to exploit. Friday nights at the Klindt household are cra-zy! One of the many, many new cmdlets I’ve recently fallen in love with is Copy-SPSite. Much like it sounds, it copies site collections. As we know, the only difference between a copy and a move is the delete at the end. Here’s the PowerShell I used to repath a site collection at to


As you can see, there’s nothing to moving the site collection, and even better there is no risk of losing data. You have the opportunity to check the copy is good before you delete the original site collection. I’ve done a little testing and Copy-SPSite seems to work great if the source and destination are in the same web application. If I try to copy a site collection to a different web application I get a weird error. That might be a limitation of the cmdlet. If so, it’s pretty easy to deal with. When you’re using Copy-SPSite you can specify a DestinationDatabase. You could copy the site collection to its own database, then move that database to a different web application.

While repathing site collections probably wasn’t the intended purpose of Copy-SPSite, it is one good use for it.




Copying the site Collection in Same web app to different DB

HI Todd,

Is it work like above demo to copy the site collection within same web app but different database?
 on 10/10/2012 7:09 PM

Re: Copying the site Collection in Same web app to different DB

Yes. The copy of the SPSite can go in the same database as the source, or it can go in a different database that you specify with the -DestinationDatabase parameter.

Todd O. KlindtNo presence information on 10/10/2012 8:24 PM

It's really useful

HI Todd,

It's really useful and thanks for sharing this information.
 on 1/8/2013 11:56 PM

Need some guidance here...

Todd,...I'm running SP2010,...and I was asked to create a new section within my company's root SP site....No problem,...I created a flyout on the root site's main menu and then folks go to these new pages.  Now for the disaster!!!

They have decided that they want the new additional pages (over 50 pages) to become it's own site. It can be on the same database and same server,..but they want it to be independent so that it can have it's own search scopes, site maps etc.....

Can I create a new "site" rather than new "page" like I did previously and then copy each page (all 55) into the new site? If so,..what happens to the myriad of links that I had on these pages that pulled from the root site's site assets folder?

Would it be better to copy the root site,.....rename it and then delete all of the pages but the 55 that I need? Will that still mess up links?

I'm still rather green with SP, so I'm a little unsure about such matters.

The Main site has this url string for example:

When you go to the new area (which are just pages built within the root, it would look like this:
 on 4/29/2013 8:53 AM

Make sure to test

Always test the new site before deleting the old one. I had several occasions where the copy completed without an error but the new site did not work. Running the command again (with a different TargetUrl) solved the issue.

Never found the exact cause of this.
 on 5/22/2013 10:16 AM

SharePoint Online

Hi Todd,

We are running SharePoint online (their plan 2 which is close to Enterprise features): does Copy-SPSite work in that environment (it does not show in the SPO cmdlet package I installed)? I tried posting this question in MS forums but did not get an answer... it may be that I am just out of luck as I do not see a Copy-SPOSite command which may be it...

Any answer would be greatly appreciated,

Paul A.
 on 6/5/2013 10:54 AM

Re: SharePoint Online

I don't see a way to do that with SharePoint Online. Just another good reason to stay onpremises.

Todd O. KlindtNo presence information on 6/9/2013 3:20 PM

Content And Structure

Thanks Todd, Another great method for moving or Re-Pathing a 2010 site is to use the Content and Structure page to MOVE a Site
 on 7/30/2013 1:54 PM

Re: Content And Structure

Hi John,
The Content and Structure only allows you to move webs (spweb) within a site collection (spsite). This is dealing strictly with site collections, or spsites. You can't rename an spsite with the Content and Structure page.

Todd O. KlindtNo presence information on 7/31/2013 9:24 PM

Different Web Application

Hi Todd,
This command so rocks! I am wondering if you have had any luck with the -HostHeaderWebApplication to copy the site collection from a production web app to a test web app. I have had success using the backup and restore commands to do this but thought that if using copy-spsite was an option that would be great!

Thanks Again for this post - it's been so helpful!
 on 8/22/2013 9:45 AM
1 - 10Next

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.


Body *

Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person


Want a message when I reply to your comment? Put your Twitter handle here.