Copy-SPSite - Clone SharePoint Site Collection using PowerShell

Copy-SPSite is a new feature introduced in SharePoint 2013, allows us to copy an existing site collection in to a new site collection. Copy-SPSite cmdlet clones/duplicates existing site collection into new one. Optionally, You can specify "Destination Database" parameter to copy the site collection into new database.

Copy-SPSite Example:
Copy-SPSite {Source-Site-Collection-URL} [-DestinationDatabase {Destination-Database-Name}] -TargetUrl {Target-Site-Collection-URL}
Copy-SPSite -TargetUrl -DestinationDatabase SP13_Intranet_ContentDB005
This gets you a duplicate of a site collection on a fresh new URL!  

Using Copy-SPSite cmdlet to rename existing site collection:
To rename site collections, we used to follow backup-delete-restore process as in my another article: Rename site collection in SharePoint 2010 using PowerShell. Of course, there is a risk involved as you delete site collections - There are chances to loose data. Fortunately, SharePoint 2013 came with new functionality "Copy-SPSite". As the name suggest, Its used to make a copy of SharePoint site under a new name (URL) without any risk of losing data!

Tips: Want to copy SharePoint site to another server? Use Backup-SPSite and Restore-SPSite cmdlets to copy site between farms!

Copy SharePoint site to another web application
While its simple and straight forward to copy site to different site collections, I had few glitches while copy SharePoint site to another web application. Copy SharePoint site to another web application using Copy-SPSite doesn't work!
Copy-SPSite : The site collection being moved and the destination content database must be within the same Web application.
copy-spsite different web application
Solution: Use Backup-SPSite and Restore-SPSite cmdlets!

Copying Host Named Site Collections
I tried copy a SharePoint site to another on path-based site collections, It went through well. But when I tried copying a host-named site collection, ended up with an error!
Copy-SPSite -Identity '' -TargetUrl '' -HostHeaderWebApplication ''
and got this error:
Copy-SPSite : Another site already exists at Delete this site before attempting to create a new site with the same URL, choose a new URL, or create a new inclusion at the path you originally specified.
copy-spsite site already exists
Workaround: Remove site url and then run copy site!
Remove-SPSiteURL -URL http://your-hnsc-site-url
You can't copy a site collection in SharePoint 2007/SharePoint 2010/SharePoint 2013 within the same content database!


  1. Very important notice at the bottom:
    You can't copy a site collection in SharePoint 2007/SharePoint 2010/SharePoint 2013 within the same content database

  2. i, I tried to rename site using copy-spsite command, the command ran with no errors but there was no new site created. If I check Central Admin, I can see the new site url there, but it has no information and I cannot select and delete the site.
    I tried deleting using PS (remove-spsite), no luck. How do I delete this orphaned site?


Please Login and comment to get your questions answered!

Powered by Blogger.