Backup/Restore-SPSite and the Missing Term Set!


One of my customers recently wanted to move a Site Collection into a new Content Database, however instead of using Move-SPSite to do this they decided to use Backup/Restore-SPSite and here is where the fun began! 

One of the key differences between using Move-SPSite and Restore-SPSite is that Restore-SPSite will assign a new GUID to the Site Collection as part of the restore process, one of the results of this is that the Site Collection Term Set will lose its mapping and will be in-accessible - the reason for this is that the ACL for the Term Set uses the Site GUID and if the Sites GUID changes, it will not have access to its Site Collection Term Store.

The result of this for my customer was that the Site Collection Term Set vanished and was inaccessible when the Site Collection that had been restored, fortunately this is fairly easy to resolve using the steps below:

  • Determine the GUID (UniqueId) of the Site Collection Term Set - This can be obtained by querying the MMS Service Application database. In the example below the Site Collection was named "qwerty".

  • Execute the following script - Replacing TermSetGUID with the UniqueId obtained in the step below and SiteURL with the URL of Site Collection that you need to grant access to the Term Set. Please run with an account that has "Full Control" permissions on the MMS Service Application and is a "Term Store Administrator"

asnp *sharepoint* -ea 0
$TermSetGUID = "TermSetGUID"
$Site = Get-SPSite "SiteURL"
$TermSet = Get-SPTaxonomySession -Site $Site
$Group = $TermSet.DefaultSiteCollectionTermStore.Groups | Where {$_.Id -eq $TermSetGUID}
$Group.AddSiteCollectionAccess($Site.Id)
$Group.TermStore.CommitAll()


Brendan Griffin - @brendankarl

Comments (5)

  1. Mihir Sheth says:

    Thank you for this article!! We ran into exactly this scenario, and this successfully got us out of this jam 🙂

  2. pk says:

    Hi

    When follow the scipt I find the error folow below:
    You cannot call a method on a null-valued expression.
    At line:1 char:1
    + $Group.AddSiteCollectionAccess($Site.Id)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    can you please advice me how to fix it

    Regard
    PK

  3. PK says:

    Hi

    It look like only can appy on same machine, but if restore the site to other machine, how recovery the term store for the site to use the old term store setting with config.

    Regards
    PK

  4. @PK – as the data is stored in the MMS Service Application database (which will be different in the destination farm). You’d need to write something to export/import the relevant terms and hookup to the Site Collection.

  5. PK says:

    Thank you, Brendan Griffin
    Do you have any detail solution let me try.

Skip to main content