LinkedIn

Thursday, April 28, 2011

Disaster Recovery in SharePoint Server 2010

Overview:


We define disaster recovery as the ability to recover from a situation in which a data center that hosts SharePoint Server becomes unavailable. The disaster recovery strategy that you use for SharePoint Server must be coordinated with the disaster recovery strategy for the related infrastructure, including Active Directory domains, Exchange Server, and Microsoft SQL Server.

The time and immediate effort to get another farm up and running in a different location is often referred to as a hot, warm, or cold standby. Our definitions for these terms are as follows:


Cold standby Second data center that can provide availability within hours or days. Have backups on a regular basis, and has contracts in place for emergency server rentals in another region. You can recover by setting up a new farm in a new location, (preferably by using a scripted deployment), and restoring backups. Or, you can recover by restoring a farm from a backup solution such as Microsoft System Center Data Protection Manager 2007 that protects your data at the computer level and lets you restore each server individually. Often the cheapest option to maintain, operationally.

Often an expensive option to recover, because it requires that physical servers be configured correctly after a disaster has occurred. The slowest option to recover.

Warm standby A second data center that can provide availability within minutes or hours. . A business ships virtual server images to local and regional disaster recovery farms. You can create a warm standby solution by making sure that you consistently and frequently create virtual images of the servers in your farm that you ship to a secondary location. At the secondary location, you must have an environment available in which you can easily configure and connect the images to re-create your farm environment. Often relatively inexpensive to recover, because a virtual server farm can require little configuration upon recovery. Can be very expensive and time consuming to maintain.

Hot standby A second data center that can provide availability within seconds or minutes. A business runs multiple data centers, but serves content and services through only one data center. You can set up a failover farm to provide disaster recovery in a separate data center from the primary farm. An environment that has a separate failover farm has the following characteristics:

• A separate configuration database and Central Administration content database must be maintained on the failover farm.

• All customizations must be deployed on both farms.

• Updates must be applied to both farms, individually.

• SharePoint Server content databases can be successfully asynchronously mirrored or log-shipped to the failover farm

Often relatively fast to recover. Can be quite expensive to configure and maintain.



Backup and recovery overview (SharePoint Server 2010):

The backup architecture and recovery processes that are available in Microsoft SharePoint Server 2010, including farm and granular backup and recovery, and recovery from an unattached content database. Backup and recovery operations can be performed through the user interface or through Windows PowerShell cmdlets. Built-in backup and recovery tools may not meet all the needs of your organization.

Backup and recovery scenarios

Backing up and recovering data supports many business scenarios, including the following:

• Recovering unintentionally deleted content that is not protected by the Recycle Bin or versioning.

• Moving data between installations as part of a hardware or software upgrade.

• Recovering from an unexpected failure.



Backup architecture

• SharePoint Server 2010 provides two backup systems: farm and granular.

Farm backup architecture

• The farm backup architecture in SharePoint Server 2010 starts a Microsoft SQL Server backup of content and service application databases, writes configuration content to files, and also backs up the Search index files and synchronizes them with the Search database backups.

Granular backup and export architecture

• If you are running SQL Server Enterprise, the granular backup system can optionally use SQL Server database snapshots to ensure that data remains consistent while the backup or export is in progress. When a snapshot is requested, a SQL Server database snapshot of the appropriate content database is taken, SharePoint Server uses it to create the backup or export package, and then the snapshot is deleted. Database snapshots are linked to the source database where they originated. If the source database goes offline for any reason, the snapshot will be unavailable.

References:
http://technet.microsoft.com/en-us/library/ff628971.aspx
http://technet.microsoft.com/en-us/library/ee663490.aspx

Thursday, April 14, 2011

SharePoint 2010 custom masterpage with code behind file

Master Page code behind should like this:

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MasterPageWithCodeBehind.MasterPageModule

{

public class _starter : MasterPage

{

protected System.Web.UI.HtmlControls.HtmlGenericControl divRibbonContainer;
protected Label Label1;

protected void Page_Load(object sender, EventArgs e)
{

     divRibbonContainer.Visible = false;
     Label1.Text = "Hello World!";
}

}

}
 
In the application pages you should have a attribute like this:
Add the following Inherits attribute:
Inherits :
To combine the code-behind file with the masterpage there need to be an attribute added to the masterpage directive.
The following data is needed:
■Namespace of the class & Type/Class name (these need to be seperated by a dot) (MasterPageWithCodeBehind.MasterPageModule._starter)

■Strongname/Assembly in my case was this the same as the projectname (MasterPageWithCodeBehind)

■Version (Version=1.0.0.0)

■Culture (Culture=neutral)

■PublicKeyToken (PublicKeyToken=f8a88530fbc7b81b)In the masterpage navigate to the following:

In our case the Inherits would contain:
MasterPageWithCodeBehind.MasterPageModule._starter, MasterPageWithCodeBehind, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f8a88530fbc7b81b
 
Deploy your SharePoint 2010 project and load the default site.Your ribbon should be gone and a text like Hello World! should be visible.
Refer the following link for details:
http://rburgundy.wordpress.com/2010/03/10/sharepoint-2010-custom-masterpage-with-code-behind-file-%e2%80%93-part-2/

Friday, April 8, 2011

Rendering a document file from a document library on web part in HTML format

The following is the code for rendering a document file in a document library in sharepoint as html file in a iFrame in a web part. This will be very userfull if you want to render a document in readonly mode on browser.
string url = SPAccessLayer.DownloadAndConvertFile(url of document in the document library);


string name = "QueryStringPageViewer_" + this.UniqueID;

output.AddAttribute(HtmlTextWriterAttribute.Id, name, false);

output.AddAttribute(HtmlTextWriterAttribute.Name, name, false);

output.AddAttribute(HtmlTextWriterAttribute.Width, "100%", false);

output.AddAttribute(HtmlTextWriterAttribute.Height, "60%", false);

output.AddAttribute(HtmlTextWriterAttribute.Height, "60%", false);

output.AddAttribute(HtmlTextWriterAttribute.Src, url, false);

output.AddAttribute("ddf_src", url, false);

output.AddAttribute("frameBorder", "0", false);

output.RenderBeginTag(HtmlTextWriterTag.Iframe);

output.RenderBeginTag(HtmlTextWriterTag.Div);

output.Write("IFrames not supported by this browser");

output.RenderEndTag();

output.RenderEndTag();


SPAccessLayer.cs:

public static string DownloadAndConvertFile( string itemUrl)
{
string DestFile = string.Empty;
string DestHtmlFile = string.Empty;
string listFileName = string.Empty;
string pDestFilePath = @"C:\Inetpub\wwwroot\wss\VirtualDirectories\4568\Doc";
string pDestHtmlPath = @"C:\Inetpub\wwwroot\wss\VirtualDirectories\4568\HTML";
string DestinationHTMLFilePath = ConfigurationSettings.AppSettings["DestinationHTMLFilePath"];
string DocumentDownloadedPath = ConfigurationSettings.AppSettings["DocumentDownloadedPath"];
pDestFilePath = DocumentDownloadedPath;
pDestHtmlPath = DestinationHTMLFilePath;
SPListItem aItem = SPContext.Current.Web.GetListItem(itemUrl);
if (aItem != null)
{
listFileName = aItem["FileLeafRef"].ToString();
if (listFileName.ToUpper().EndsWith("X"))
listFileName = listFileName.Substring(0, listFileName.Length - 1);
byte[] byteFile = aItem.File.OpenBinary();

//HttpContext.Current.Response.Write(DestFile);


if (listFileName.Contains(".doc"))
{
DestFile = pDestFilePath + listFileName;
FileStream fStream = File.Create(DestFile);
fStream.Write(byteFile, 0, byteFile.Length);
fStream.Close();
DestHtmlFile = OfficeUtility.ConvertWordToHTML(listFileName, pDestFilePath, pDestHtmlPath);
}
else
{
DestFile = @"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\MetropolisDocuments\HTMLFiles\" + listFileName;
FileStream fStream = File.Create(DestFile);
fStream.Write(byteFile, 0, byteFile.Length);
fStream.Close();
DestHtmlFile = listFileName;
}
}
//HttpContext.Current.Response.Write(DestHtmlFile);
return pDestHtmlPath + DestHtmlFile;
}

Could not load type 'System.Data.Services.Providers.IDataServiceUpdateProvider'

If you are getting the following error message: Could not load type 'System.Data.Services.Providers.IDataServiceUpdateProvider' from assembly 'System.Data.Services, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The issue is with the ADO.Net Services v1.5. Please refer the link below for solution: http://blog.hompus.nl/2010/03/26/could-not-load-type-idataserviceupdateprovider-when-using-rest-with-sharepoint-2010/