Monday, February 18, 2013

How to Restore SharePoint MySites from Backup

The Story

On Friday I had a very bad surprise. All managers from the company were waked with this emails like:

Subject: The My Site of X Y is scheduled for deletion

The My Site of X Y is scheduled for deletion in 14 days. As their manager you are now the temporary owner of their site. This temporary ownership gives you access to the site to copy any business-related information you might need. To access the site use this URL: https://mysites.portal.domain.local/personal/xy


Pretty uncomfortable. The day before this I deleted the AD Sync Connection from SharePoint's User Profile Service Application and this caused it. The sync job ran and with no connections SP thought that all the users have been deleted.

Theoretically there should be 14 days until these profiles are deleted but for some reason I can't see past activity for the use users.

Long story short, I need to restore MySites from a backup.


The Process

The restoring process is simpler than thought. Later I found out that I had to restore the User Profile Service Application as well, I will detail that later.


Restoring MySites from Backup


1. Unmount the MySites Content Database 
Unmount the MySites content database by going to Central Administration -> Application Management -> Manage Content Databases.



Select the MySites Web Application on the right



Check Remove Content Database and click OK





2. Restore the Database in SQL Server Management Studio from backup


3. Add back the content database in Central Administration

Central Administration -> Application Management -> Manage Content Databases.

Select the Mysites Web Application on the right

Click on Add Content Database and fill out the form






I had another issue: The profiles' data was wiped. I am referring to the content seen under the marked tabs:




This data is stored in the User Profile Service Application's databases (Profile Database and/or Social Database, not sure). So these had to be restored as well.



Restoring the User Profile Service Application from Backup


The process is fairly simple as long as you have the SQL backups.


1. Stop the User Profile Service and User Profile Synchronization Service in Central Administration -> Manage Services on Server


2. Restore the Profile DB and Social DB from backup on the SQL Server
3. Start the User Profile Service and User Profile Synchronization Service in Central Admin.



7 comments:

  1. I want to know if backup is not available then how can we restore MySite because once I forget to maintain the backup and restore the data using a third party tool.

    ReplyDelete
    Replies
    1. if you don't have a backup from the SQL Database or a SharePoint backup, you could try rolling back the transaction log.
      http://stackoverflow.com/questions/4507685/rollback-a-delete-operation-using-transaction-logs

      Delete
  2. Will this restore all the user profile pictures as well? I accidentally deleted some of the user’s pics via sync and was wondering if this will do the trick.

    ReplyDelete
  3. thank you!!! you save my day!!!!

    ReplyDelete
  4. This may help me for sure. Do you know which of these DBs are responsible for user picture restoration - profile or mysite content?
    Or do you recommend I restore both? Thanks.

    ReplyDelete
  5. And the rest has to waste time in taking backup regularly because they have gone through it in the past.
    cloud review from joe

    ReplyDelete