SharePoint Pals
 | Sign In
How to restore SharePoint mysites from database backup
by Tarun Kumar Chatterjee 9 Jun 2016
.Net – Technology Specialist
Today  :   21     Total  :    2136

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


· Change the Webapplication where we have the Mysites


· Make the existing pointed database as Offline


· Now Click on Add Content Database


· Point the restored SharePoint_Content_MySites database and Click on ok.

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


· 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


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 –Path "C:\Mysites_export\tkumarch1_export.cmp"
 Export-SPWeb –Path "C:\Mysites_export\tkumarch2_export.cmp"

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

 import-SPWeb –Path "C:\Mysites_export\tkumarch1_export.cmp"
 import-SPWeb –Path "C:\Mysites_export\tkumarch2_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

blog comments powered by Disqus

SharePoint Pals

SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile


Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community

SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to in a word document.

Related Resources

Recent Tweets

Twitter October 23, 22:21
How to Add/Remove User Custom Actions (in Site Actions Menu) Programmatically using CSOM PNP in SharePoint -

Twitter October 21, 21:34
How to Add a JS Link Reference to the Display Form or Any other ASPX Programmatically using CSOM PNP in SharePoint -

Twitter October 20, 13:01
How to Add a JS Link Reference to the NewForm and EditForm Programmatically using CSOM PNP in SharePoint Office 365-

Twitter October 12, 12:15
How to Deploy Provider Hosted Apps (Add-Ins) by App Stapling in SharePoint Office 365 -

Twitter October 11, 13:39
How to Deploy Provider HostedApp programmatically using CSOM in SharePoint Office 365 Activating Developer Feature -

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation