SharePoint 2016: Rename Site Collection URL Best Practice
Everyone wants to know what is the best way to change the URL of a Site Collection. There are many ways to do it. Let's show all the possible methods to perform a rename of the site collection.
Scenario:
We have a situation where we want to rename http://www.krossfarm.com/sites/testwaqas to http://www.krossfarm.com/sites/testwaqas-new. Let's see which option is good.
There are three methods to perform this:
- Using the Backup And Restore method
- Use the Copy-SPSite
- Using the Rename method of SPSite
Comparison of methods:
Listed below are the Pros/Cons of all three methods.
Options | Backup & Restore | Copy-Spsite | SPSite.Rename |
Cross Web Application | Yes | No | No |
Cross Farm | Yes | No | No |
App Pool Recycle | NO | No | Yes |
IIS reset | No | No | No |
New Site ID | No | Yes | No |
Work with path based | Yes | Yes | Yes |
Work with HNSC | Yes | No | Yes |
Create new Site collection | Yes | Yes | No |
Customization Support | Yes | No | Yes |
Recommended | Yes | No (For upgrade purpose only) | Yes (For HNSC only) |
Backup & Restore Method:
This is the old and traditional way to change the URL of a site collection. A lot of people we know used this method. But some time large sites or a large number of site collections require time. This method is time-consuming and requires downtime for the site collection.
- Backup-SPSite http://www.krossfarm.com/sites/testwaqas -Path D:\Backup\testwaqas.bak
- Restore-SPSite http://www.krossfarm.com/sites/testwaqas-New -Path D:\Backup\testwaqas.bak
- Now test the site collection. If everything works then remove old site.
- Remove-SPSite -Identity "http://www.krossfarm.com/sites/testwaqas" -GradualDelete -Confirm:$False
SPSite.Rename:
This new method was introduced initially for HNSC collections but working for the path-based site collections. This is an easy method but with limitation. The main drawback is you have to recycle the App Pool of the web app in order to refresh the cache. If you forget the App Pool recycle then site collection information is not visible in Central admin. This method only renames the site collection URL and does not convert the site collection.
- $site = Get-SPSite http://www.krossfarm.com/sites/testwaqas
- $uri = New-Object System.Uri("http://www.krossfarm.com/sites/testwaqas-new")
- $site.Rename($uri)
Copy-SPSite:
Copy-SPSite cmdlet is part of the upgrade and migration commands that is used to make a copy of the site collection to test and verify the upgrade process. This command is not recommended for day-to-day operations due to its limitation towards customization. But if you have an OOTB SharePoint site, then you can try this.
- Copy-SPSite “http://www.krossfarm.com/sites/testwaqas” -DestinationDatabase KF-ContentDB –TargetUrl “http://www.krossfarm.com/sites/testwaqas-Copy”
- Now test the site collection. If everything works then remove the old site.
- Remove-SPSite -Identity "http://www.krossfarm.com/sites/testwaqas" -GradualDelete -Confirm:$False
Conclusion:
As we can see, only Backup & Restore method is a nice clean solution with the complex site collections. This method also has the flexibility to move the site collections between web applications and farms. Rename Method is also great but due to web app limitation put it down a little. Copy-SPSite is only for the upgrade process verification, not intend for the day-to-day use.