12

I have read these links which talks about using Backup-SPsite && Restore-SPSite:-

and they both mentioned that restoring a copy of a site collection's back-up file file using Restore-SPSite will mainly create a new GUID for the site but will reserve the GUID for the site collection's components such as its subsite, content type, etc... so they mentioned that we should do the Restore-SPSite on a new Content Database to avoid GUID conflict..

so I did the following test:-

  • I have the following site collection "http://..../businessfunctions".
  • I backup it.
  • then I restore a new site collection (http://..../testsite) using the backup file inside the same content database (Actually I only have one content database).
  • and I did not get any exception,, or any error message about any GUID conflict..

so now I have 2 site collections (/businessfunction & /testsite), that have the same GUIDs for their; subsites, content types, etc... but I am able to work on these 2 site collections without having any problem.

So can anyone adivce why all the links which talk about Restore-SPSite mentioned that we need to restore on a different content database to avoid duplicate or conflict in GUIDs ??? In other words where I will face problems if I have for example 2 subsites that have the same GUIDs ,and their site collections are inside the same content database?? Here is a screenshot of the scripts which I perform:-

enter image description here

8
+100

Just look at the code snippet below and try to imagine the scenario of what will happen:

using(SPSite site = new SPSite("http://somesite")) {
    using (SPWeb web = site.OpenWeb(SameGuid)) {
        return web.Url;
    }
}

The above code can raise an exception because two web objects would be returned, there are infinite scenarios where GUID is used to fetch an instance and every time there would be 2 cases:

  1. It will take the first one (Worst case)
  2. Throw an Exception (Developer will scratch his head!)

To maintain data integrity, avoid future hassle regarding scalability and enhancement, it is advised to restore Sp-Site under new Content DB.

GUID for a site collection is unique and it gets stored along with the site collection backup. Your content database has a table called dbo.sites with a column named "id"

enter image description here

At the end I would just say that even if you are able to Restore-SpSite with some workaround, it would be a big design flaw and would create problems in the future as this blog states.

  • 1
    but even if i restore on new content DB ,, i think all the site collections's content such as subsites, lists, etc will still have the same gUID as their source site collection is this correct ?? also in your code snippet still two web objects will be returned even if they are inside seperate content DB..,, or if i restore on new content db all the site collection's content will get new GUID compared to their source ? – john Gu Sep 28 '15 at 7:35
  • Your content database has a table called dbo.sites with a column named "id". I would really suggest you to read this article sharepointinterface.com/2011/04/03/… – Taran Goel Sep 28 '15 at 7:47
  • but using Restore-SPSite will create new GUID for the site even on the same content database,, so the id will not be duplicated – john Gu Sep 28 '15 at 8:44
  • 1
    creating a different content db would be a workaround to get the site restored but it would not be a good solution. You can look into Export-Import of site – Taran Goel Sep 28 '15 at 8:47
  • 1
    MS didn't allow us to manually give guid to a component and there's a reason behind it :) – Taran Goel Sep 28 '15 at 9:00

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.