Move SharePoint sites to a new location - Site Swap
Microsoft introduced with the SharePoint Online Management Shell version 16.0.8812.1200 the capability to swap SharePoint Online root site or /search site in your tenant.
Tenants that were provisioned before April 2019 have only two ways to change the root site collection to a modern site. They can use the site swap feature presented in this post or enable the communication site feature. The latter feature is not available yet and will be useful for sites that already have contents. Microsoft will provide an update about this feature in the future.
Ensure that you have the latest version of the SharePoint Online Management Shell. The next code snippet shows how you could run the command.
The script above will take the source site and store it either in the root site or /search site of your tenant. The previous site in that location will be archived to the archive URL your are specifying. This allows you to rollback your changes if required.
Some remarks
- The target site may return a not found (HTTP 404) error for a short period of time (up to about 5 minutes)
- Content will need to be recrawled to update the search index for the sites that have been swapped. This may take a period of time depending on various factors such as the amount of content in these sites. Anything dependent on the search index, may return incomplete results until the swapped sites have been recrawled.
- Anything dependent on static links (such as File Sync and OneNote files) will need to be manually corrected.
Further resources