1

I am working on SharePoint server 2013 web application and i have a site collection of type team site named "business functions", and it have three subsites. where all the columns were defined inside the site collection level.

now i want to copy these 3 subsites to a new site collection (and i want to keep the original subsites as is ), so i did the following steps:-

  1. i save the three subsites as site template.
  2. then i download the generated wsp files.
  3. i upload the three wsp site templates inside the new site collection.
  4. after that inside the new site collection i created three new sub sites based on the 3 wsp site templates.

now from my first test i thought that the sub-sites were copied successfully. but after some detailed testing i realized that i am facing this strange problem . now on the original site collection i created all the site columns at the site collection level. for example here are 6 site columns defined at the site collection level (site collection name is Business functions):-

enter image description here

but when i create a new sub-site on the new site collection based on the site template, i have noted that these site collection columns will be created as a sub sites columns as follow (sub site named is dev):-

enter image description here

so can anyone adivce what is causing this problem and how i can fix this ?

second question. is there a better way to copy my sub-sites to the new site collection, and to keep the exact behavioure for the site columns and content types. ?

EDIT:-

here is how my content database looks like:- enter image description here

  • Is it possible to create the template from the root site of the site collection? I understand that the root site may not need to have the sub-site (that should act as template) but this may solve the problem! – Vamsi K K Sep 25 '15 at 20:30
1

If you don't have many sites, you can try copying the whole site collection. Since you wrote "copy webs to a new site collection", this approach would work. Make a backup of the site collection that has your web sites in it and restore it to a new site collection:

Backup-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak
Restore-SPSite http://server_name/sites/new_site_name -Path C:\Backup\site_name.bak

Then get all the webs except the ones that you want to leave (based on server relative url. Don't forget to include root web!) and remove them.

$webURLsToKeep = "/sites/new_site_name", "/sites/new_site_name/1", "/sites/new_site_name/2", "/sites/new_site_name/3"
$site = get-spsite http://server_name/sites/new_site_name
$site.AllWebs | ? {$webURLsToKeep -notcontains $_.ServerRelativeUrl} | ForEach-Object {$_.Delete()}

That way you would keep your site collection configuration including all site columns.

Hope this helps.

  • thanks for the reply i will try your approach. but can you advice on these 2 points . 1) can i copy a site collection by backuping and restoring it on a new url at the same web application as u mentioned, or i will get an error that the database id already exists .. 2) second question now backuping and restoring the whole site collection will copy its subsites also so not sure what is the benefit of your second script ? can u adivce please? – john Gu Sep 23 '15 at 10:47
  • 1
    1. Yes you can restore in the same web application, just specify a new URL. 2. This is in case you have 20 sites in your old site collection and just want 3 sites (for example) copied over. – Paul Strupeikis Sep 23 '15 at 10:49
  • ok i got your point . but i am trying to find the best solution to copy sub-sites from on SC to another. so in general which approach you will use ? i find that there are 3 approaches; 1) i can use site template (but it will have problems as i mentioned on my original question), 2) also there is the approach to import, export subsites (i did not try this before) 3) and the site collection backup and restore appraoch .. so which one is more suitable or is designed to do such a task (copy sub-sites from one site collection to another) – john Gu Sep 23 '15 at 11:08
  • I guess there is no designed way to do it as every time it is different based on requirements. I would suggest you look into Export-SPWeb and Import-SPWeb PowerShell commands. PowerShell scripts should be the preffered way of doing these kind of tasks. – Paul Strupeikis Sep 23 '15 at 11:39
  • but of i use import & export will i face the same problem regarding the site columns when i used the site templete approach ? – john Gu Sep 23 '15 at 13:25
0

issue is you created the column at site collection, now you moving only the sub-sites but your columns are site level.

backup and restore is the best option. But within same web app you cant restore two site collections with same id in same content db. you need to create a new content Db then restore the site with new url.

another method i am thinking, you may try it. create the same column on destination site collection and then try import/export.

  • now for the backup & restore the site collection. i tried the following.I backup the old site collection "Business Functions", then i create a new site collection inside the same web application , then i restore the backup file on the new URL and i did not get any problem.. i used the following restore script "Restore-SPSite -Identity http:/servername/newSC -Path c:\new.bak -DatabaseServer SharePoint -DatabaseName WSS_Content -force" .. at the beginning i thought that i can not restore the same site collection on the same web application,, but seems this can be done... – john Gu Sep 23 '15 at 16:05
  • also on the other reply Paul mentioned that i can "Yes you can restore in the same web application, just specify a new URL. " so not sure what do u mean by "within same web app you cant restore two site collections with same id in same content db".. thanks – john Gu Sep 23 '15 at 16:07
  • how many content DBs you have in your web application? – Waqas Sarwar MVP Sep 23 '15 at 17:02
  • i only have one content database that hold all the site collections.. i provided a screen shot of my content database setting inside my CA – john Gu Sep 23 '15 at 17:04
  • 1
    because backup and restore never create a new guid. I always get the error when i tried in past. only thing i am thinking you created the new site collection in advance but in my case it failed all the time.only way i have to export the whole site collection then import it on new url. – Waqas Sarwar MVP Sep 23 '15 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.