Subscribe: SharePoint SharePoint SharePoint
Showing posts with label Import a term set SharePoint. Show all posts
Showing posts with label Import a term set SharePoint. Show all posts

Wednesday, January 29, 2014

Migrating Managed Metadata Term Stores in SharePoint Server across Farms

While moving a site from development environment to production environment, it is recommended to move MMS term stores too. We can actually adopt two approaches to this:

1. Export Term Stores in a .csv file and then Import them to target server.
2. Use a powershell script to create a .cab file to import on target server.

SharePoint

The first approach is easier but has a major drawback. It does not persist the GUID of the terms. This may lead to many errors in the imported site because some web parts might be dependent on a term's guid.

e.g. if i have a CQWP which shows filtered data as per a MMS term, then in the target server the filtering would be lost.

So a better and safe way is to export and import MMS using Powershell:

Export

SharePoint

 Add-PSSnapin Microsoft.SharePoint.Powershell
 $metadataApp= Get-SpServiceApplication | ? {$_.TypeName -eq "Managed Metadata Service"}
 $mmsAppId = $metadataApp.Id

 $mmsproxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"}
 Export-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path "C:\Users\Desktop\MMD.cab”

Import


SharePoint

Add-PSSnapin Microsoft.SharePoint.Powershell
 $metadataApp= Get-SpServiceApplication | ? {$_.TypeName -eq "Managed Metadata Service"}
 $mmsAppId = $metadataApp.Id

 $mmsproxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"}

Import-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path "//SharedPath/Users/Desktop/MMD.cab" -OverwriteExisting;

NOTE: While importing make sure the .cab file is in a network path accessible to SQL Server with ContentDB and which has been shared with the user account of the MMS Service.