I need to move a site from one site collection to another. I don't need to move an entire site collection; just a sub-site on that collection. What is the easiest way to do this?
Export and import the easy way to move the subsite around. But i always followed the below script which is equal to export/import but also add one more step create the subsite on destination with same template as used on source. You need to change the parameters and save the file as .PS1 and run it.
# add SharePoint snapin Add-PSSnapin Microsoft.SharePoint.PowerShell –ea SilentlyContinue # set variables $exportfolder = "C:\Site exports" $exportfile = "\site_export.cmp" $exportsite = "http://vm353/PWA/PAULMATHERTESTSITE" $exportlocation = $exportfolder+$exportfile $importlocation = "http://vm353/PAULMATHERTESTSITE" #get export site's template $web = Get-SPWeb $exportsite $webTemp = $web.WebTemplate $webTempID = $web.Configuration $webTemplate = "$webTemp#$webTempID" $web.Dispose() #create export folder $null = New-Item $exportfolder -type directory #export site Export-SPWeb $exportsite –Path $exportlocation -IncludeUserSecurity -IncludeVersions 4 Write-host "$exportsite has been exported to $exportlocation" #create new site ready for import $null = New-SPWeb $importlocation -Template "$webTemplate" Write-host "$importlocation created ready for import" #import site Import-SPWeb $importlocation –Path $exportlocation -IncludeUserSecurity –UpdateVersions 2 Write-host "$exportsite has been imported to $importlocation" -foregroundcolor "Green"
Another approach is use the 3rd party tool if you are going to different between different farms.
Export sub-site from old site collection using this command:
export-spweb "http://host/sites/OldsiteCollection/xyz" -path "D:\Temp\migration\backupfile.cmp" -IncludeUserSecurity
Import subsite to my new site collection using this command:
Import-SPWeb "http://host/sites/NewsiteCollection/xyz" -path "D:\Temp\migration\backupfile.cmp" –UpdateVersions Overwrite -IncludeUserSecurity