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 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
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.