Thursday 16 May 2013

How to restore the "default.aspx" in SharePoint Designer 2010

Hi all,

Today, I got a ticket concerning the fact that the “default.aspx” was deleted in a Site Collection.


My first question was “How did they achieve this?”, because they cannot delete system files, as SharePoint Designer 2010 access is limited at the Web Application level:



So, I had to open the Site Collection in SharePoint Designer 2010 with full access to be able to view all files.

To do this, I’ve allowed the Web Application option : “Allow Site Collection Administrators to see the URL Structure of their Web Site”
Then, I’ve opened the Site Collection in SharePoint Designer 2010, and set back the options in “SharePoint Designer Settings” as our default settings. (this, to avoid other clients to open their site in SharePoint Designer 2010 and letting them braking their site)

In SPD2010 (SharePoint Designer 2010), the “default.aspx” was missing.
But, I saw the file “Organogram.pptx” with the blue icon.
Checking it’s properties gave me the satisfaction that the “default.aspx” was overwritten by the .pptx, but was still known by SharePoint as the “default.aspx” file.





So, I decided to do a “Reset to Site Definition” of this file :



The .pptx file was “cleaned” (check it’s size), and the original faulty .pptx is now set as a copy, and not simply deleted:



Thus, I’ve renamed the “clean” .pptx into “default.aspx



A page refresh, and the client site is now up’n running again:



Job's done.

Wednesday 15 May 2013

How to Restore a Deleted Site Collection in SharePoint 2010

Hi all,

Today, I was asked to restore deleted files from a deleted Site Collection in our production farm.

As usual, when I receive this kind of request (recover deleted files) , the procedure is:

-          - Ask SQL Team to restore the DB from the day before deletion
-          - Mount the DB in a  specific Web Application
-          - Set the restored DB as “Offline” in Central Administration
-          - Go to the site and export the deleted files to the client’s SharePoint Site
-          - Remove the restored DB from the Web Application
-          - Delete the DB from SQL


The SQL Corporate rules concerning the backup retention time is 14 days.

But this time, the site was deleted for 16 days, so out of the backup retention time…
No restore available.


Then, I remember that the production DB are keeping the deleted Site Collections for 30 days !!!
Thus I will be able to restore the deleted Site Collection, and my client will be happy to recover all missing files.

Steps to follow are:

-          Get-SPDeletedSite : this will give the list of all deleted Sites Collection in the Farm


In the red box, I can find the Path and the Deletion Time, that match with the info given by the client.

-          I will then restore the Site Collection with the following cmd :
Restore-SPDeletedSite –Identity “/Sites/CD10000059”
               
                /!\ A Site Collection must not already exist at the URL location to perform a restore /!\


Voilà, the site is now restored from the DB’s recycle bin.


That’s all folks


Monday 6 May 2013

How to Delete a corrupt file entry in SQL DB

Hi All,

Today, I’ll explain the way I found to clear a file issue in one of the SharePoint 2010 site.
File is visible in the AllDocs list, but not available even when opening the Library with the “Open with Explorer”  ribbon option.

The faulty file the file name mentioned in the red box hereunder, and it’s extension is .xmind (event if the icon is a pdf).

So, all the site is working like a charm, without any error.



When trying to open the file, or making any change to it via the drop-down menu of the file, I got the http 500 error :




First, I made a –databaserepair to find the corruption, and try to fix it with the –deletecorruption parameter : didn’t help.

PS C:\Users\sharepoint_install> stsadm.exe -o databaserepair -url http://<siteURL>/Sites/SiteName -databasename Sharepoint_Content_shpDBName_RestoreFromProductionForTest

<OrphanedObjects Count="2">
  <Orphan Type="SecurityScope" SiteId="{69446A31-82A4-481E-9889-4661A810AD16}" Name="Sites/SiteName/Lists/ProjectDocuments /P131070_SmartMonitoring_WBS.xmind" InRecycleBin="No" />
  <Orphan Type="SecurityScope" SiteId="{96A99C51-C636-4593-BF9C-ED610ACA4743}" Name="Sites/SiteName/Lists/ProjectDocuments /P131063_Project_Definition_One Number_draft v0.1.docm" InRecycleBin="No" />
</OrphanedObjects>

PS C:\Users\ sharepoint_install> stsadm.exe -o databaserepair -url http://<siteURL>/Sites/ SiteName -databasename Sharepoint_Content_shpDBName_RestoreFromProductionForTest

Violation of PRIMARY KEY constraint 'Perms_PK'. Cannot insert duplicate key in object 'dbo.Perms'. The duplicate key value is (96a99c51-c636
-4593-bf9c-ed610aca4743, 0x, Sites/SiteName/Lists/ProjectDocuments/P131063_Project_Definition_One Number_draft v0.1.docm).
The statement has been terminated.



Then, I decide to open SQL, and start finding the document entries.
Of course, there is no clear post/site/info showing all the tables to check.

I found 2 tables :
-          AllDocs
-          AllDocStreams


First things first :

1.       Find the file in the AllDocs table and grab the Id entry

/****** Script for SelectTopNRows command from SSMS  ******/
SELECT *
  FROM [Sharepoint_Content_shpDBName_RestoreFromProductionForTest].[dbo].[AllDocs]
  WHERE [DirName] like 'Sites/SiteName/Lists/ProjectDocuments'
/**********************************************************/


The result is :


So, I have the unique Id, and looking at the column named “DocLib RowId” let me do a double-check that the file is the correct item to delete (check the ID row in the List from the first screen).


2.       Find the same Id entry in the AllDocStreams table

/****** Script for SelectTopNRows command from SSMS  ******/
SELECT [Id]
      ,[SiteId]
      ,[Content]
      ,[RbsId]
      ,[InternalVersion]
FROM [Sharepoint_Content_shpDBName_RestoreFromProductionForTest].[dbo].[AllDocStreams]
WHERE [Id]='DEF629C6-3A40-473A-BDD5-BB295E9E1AB1'
/**********************************************************/




3.       Delete both entries in the SQL DB :

/****** Script for SelectTopNRows command from SSMS  ******/
DELETE
  FROM [Sharepoint_Content_shpDBName_RestoreFromProductionForTest].[dbo].[AllDocStreams]
  WHERE [Id]='DEF629C6-3A40-473A-BDD5-BB295E9E1AB1'
/**********************************************************/

Result : (1 row(s) affected)



/****** Script for SelectTopNRows command from SSMS  ******/
DELETE
FROM [Sharepoint_Content_shpDBName_RestoreFromProductionForTest].[dbo].[AllDocs]
where [Id]='DEF629C6-3A40-473A-BDD5-BB295E9E1AB1'
/**********************************************************/

Result : (1 row(s) affected)


4.       Test that the file is no more listed in the Site:

Voilà, my test in the UAT farm is successful, I’ll do the changes into the Production environment.


That’s all Folks.


nb: change done with success in production.