How to restore SharePoint mysites from database backup

Tarun Kumar Chatterjee
 
Net – Technology Specialist
June 9, 2016
 
Rate this article
 
Views
8437

In one of our project suddenly Active directory was messed up because of some network issue and SharePoint user profile synch service was not able reach to Active Directory. All the users got the email notification that within 14 days all the mysites will be deleted. It became nightmare to us as it was supported by our team only & we could not say to take the manual backup individually as because user used to keep their personal information like mail backup (PST) etc. in their own mysite & so the size was also huge. It happened because of my site clean-up timer job deleting the profile if it does not find in active directory.  While deleting the profile it will also delete the manual entered personal information like note, photo and links etc. Though the active directory was available after 2 hrs but my site clean-up timer job marked all the mysites deleted flag as true, so there were no option we found to avoid the mysites deletion, even disable clean-up timer job also not worked.

After a very hard try we found an ultimate solution i.e. to take the database backup and restore the mysites after 14 days of mysites deletion. Thought of sharing with you with the details if it helps anyone. Let see the steps we followed

We can verify restorable count by running the query in sharepoint database

select * from SharePoint_Content_MySites.dbo.SiteDeletion where Restorable = 1

Before the clean-up timer job automatically delete all the mysites ,we took the below database backup and restore in a test environment rather in production environment, as because we should not touch the live box SharePoint database.

· SharePoint_SA_User_Profiles

· SharePoint_SA_User_Profiles_Sync

· SharePoint_SA_Social_Data

· SharePoint_Content_MySites

After 14 days while all the mysites are deleted we did follow the below steps

· On the Start screen, click SharePoint 2013 Central Administration.

· If SharePoint 2013 Central Administration is not on the Start screen:

Right-click Computer, clicks all apps, and then clicks SharePoint 2013 Central Administration.

· Go to Application Management and Manage Content Database

clip_image002

· Change the Webapplication where we have the Mysites

clip_image004

· Make the existing pointed database as Offline

clip_image006

· Now Click on Add Content Database

clip_image008

· Point the restored SharePoint_Content_MySites database and Click on ok.

· Go to Backup and Restore, click on Export to Site or List

clip_image010

· Change the Site Collection, select the mysite under the Site section, provide the Exported shared file path ( The file name should have cmp extension) & then click on Start Export

clip_image011

It will take some times to create the backup, will get the notfication as soon as the backup is being completed. It will generate a cmp backup file as well as a log file.

We can also export the cmp file by using the below powershell commands

 Export-SPWeb http://sharepoint.com/mysites/personal/tkumarch1 –Path "C:Mysites_exporttkumarch1_export.cmp"
 Export-SPWeb http://sharepoint.com/mysites/personal/tkumarch2 –Path "C:Mysites_exporttkumarch2_export.cmp"
 

To restore the backup we need to run the below powershell commands in production enviornment

 import-SPWeb http://sharepoint.com/mysites/personal/tkumarch1 –Path "C:Mysites_exporttkumarch1_export.cmp"
 import-SPWeb http://sharepoint.com/mysites/personal/tkumarch2 –Path "C:Mysites_exporttkumarch2_export.cmp"
 

We need to repeat the export and import for all the individual mysites which are deleted.

After all the imports are done we need to make the current content database as offline and previous pointed content database as online in test environment. That’s all, we are all set, cheers!!!

Happy coding

Tarun Kumar Chatterjee

Category : SharePoint

Author Info

Tarun Kumar Chatterjee
 
Net – Technology Specialist
 
Rate this article
 
Tarun has been working in IT Industry for over 12+ years. He holds a B-tech degree. He is passionate about learning and sharing the tricks and tips in Azure, .Net ...read more
 

Leave a comment