Wednesday, March 28, 2012

Deploying a Custom WebPart to Sharepoint

Introduction

In Part 1 of this article, I discussed how to create a custom Webpart which connects to database and pull data.
In this article (Part 2), I will show how to deploy the DatabaseConn Webpart that we have created to Sharepoint site and use it in any of your sites.

Deployment Methods

We can deploy a custom webpart in 2 ways:
  1. Deploying the Assembly (i.e. DatabaseConnWebpart.dll) to GAC
    This requires the assembly to be strong named, a change in manifest etc.
  2. Other simplest way is to deploy assembly to Sharepoint Virtual Directory folder in IIS, i.e. C:\inetpub\wwwroot\wss\VirtualDirectories\80\bin
Note: Sometimes using way 2 may create trust problems, so if you encounter that issue, try copying your DLL to GAC too. It will solve the issue.

Copying Assembly to Sharepoint BIN Folder

Sharepoint Virtual directory can be found at: C:\inetpub\wwwroot\wss\VirtualDirectories\80\bin.
Copy the DLL of DatabaseConnWebPart that we created from your project folder and paste it in the bin folder of portal directory and also GAC, c:\windows\assembly (if you encounter any trust issues).

Adding the Safe Control Entry

Even though the assembly is present in the Portal’s Bin folder, there is another step required to make the Control (Web Part) assembly usable on the Portal Pages.
Since the control will need to render on multiple machines in different browsers with as many user accounts as the organizations have, there is a need to declare the control as “safe”.
To do so, open the web.config file of Sharepoint portal placed under the portal’s directory, and look for <SafeControls> node in web.config and add the following Safe control code:
// Check for this node

<SafeControls>
………..
………....

// Add this line of code which ensures webpart is safe

<SafeControl Assembly="DatabaseConnWebPart " Namespace="DatabaseConnWebPart "
    TypeName="*" Safe="True" />

</SafeControls>
Now that we declared the webpart as safe, our webpart will be deployed to Sharepoint Portal.

Configuring Portal to Use NewWebPart

Open your Sharepoint portal and on your “Home”, click Site Actions -> Site Settings -> Modify all Site Settings as shown in this figure:
SiteSettings_small.jpg
Sharepoint will open the Settings page.
Click “Webparts” under Galleries as shown below:
webparts_small.jpg

Adding Custom Webpart to Webparts Gallery

Click “New” in toolbar to add a new webpart as shown below:
WebPartGallery_small.jpg
Sharepoint will open the webparts gallery, choose your DatabaseConnWebPart from the gallery and check the checkbox to the left of webpart and click Populate Gallery on top as shown below.
Note: You can rename your webpart anyway you want. Use the TextBox provided to the right of your webpart to rename it accordingly.
NewWebPart_small.jpg
Now we have successfully added our new custom web part to Sharepoint portal. We can go ahead and use that webpart in any site that we want.
Note : If you want to make sure whether your webpart is added to gallery or not, check the Webpart Gallery page. It should have your webpart.

Using DatabaseConnWebPart in Site

To use our new deployed webpart in a site, open the site and Click Site Actions -> Edit Page.
This will show the site in edit mode, now click "Add a WebPart" as shown below:
AddwebPart_small.jpg
This will open the Add WebPart dialog box. Choose your webpart (in Miscellaneous section) and check it and click "Add" as shown below:
Add_webparts_-WebPage_Dialog.jpg
This will add the webpart to your home page and now your homepage as shown below:
HomepageWithWP_small.jpg

Conclusion

This is how we can create custom webparts, deploy them to Sharepoint server and use them in our sites.
Happy programming!!!

Accenture Sharepoint Interview Questions Sharepoint 2010/2007

1) Tell me about your sharepoint experiences ?


2) Did you ever worked in Web Services ? How you called Webmethods ?


3) What type of Webparts you are developed in your current project ?


4) How many ways we can deploy the webpart ?    Which is the best method to deploy the Webpart ?


5) What are new features in MOSS 2007 ?


6) What are the permission levels in Sharepoint ?


7) What is Sharepoint Object Model ?


8) What are basic building blocks for Sharepoint ?


9) How many types of Event Handlers in Sharepoint ? where did you use these event handlers in your project ?


10) What are the Security levels in Sharepoint ?


11) What is the default authentication level in Sharepoint ?


12) Can we impliment Forms Authentication in Sharepoint or is there any custom Authentication ?


13) What is meant by SignIn ?


14) What is meant by MetaData Cache ?


15) How can you impliment Data Fragment cache ? What is VaryByParam ?


16) When configuring Enterprise Search 

Wednesday, March 21, 2012

Creating a Search Content Source of type Web using PowerShell


The New-SPEnterpriseSearchCrawlContentSource command in Powershell is used to create a new crawl content source for a SharePoint search application.We can view the whole set of parameters and options in this msdn article.
So , when we need to create a SharePoint Search content source, using Powershell, we use the following commands-
$searchapp = Get-SPEnterpriseSearchServiceApplication "Search Service Application"
New-SPEnterpriseSearchCrawlContentSource -SearchApplication $searchapp -Type SharePoint -name ContentSourceWithTypeSharePoint -StartAddresses http://localhost:6001/

Configuring the User Profile Service in SharePoint 2010


I first introduced Service Applications and User Profile Service Synchronization back when SharePoint 2010 was in beta, and as many of you who would have attempted this feat, would have come to realize that there were a couple of known issues, in particular those around utilizing a least privilege model with service accounts.  I’m confident in stating that these issues have now been resolved with RTM and in today’s article I will share with you my step by step guide in setting up the User Profile Service application, focusing on its configuration and administration and how we can enable the creation of user profiles via an Active Directory import .
SharePoint 2010 introduces the notion of “Service Applications” which build’s upon the “Shared Services Provider (SSP)” which was introduced in SharePoint 2007.  Service Applications are individual services that can be configured independently and can be shared across other sites within your farm with some service applications that can also be configured across farms.
The individual service applications provided with SharePoint 2010 are listed as follows;

  • Access Services
  • Business Data Connectivity
  • Document Conversion
  • Excel Services
  • Managed Metadata Service
  • PerformancePoint
  • Search Service
  • Secure Store
  • State Service
  • Visio Graphics Service
  • User Profile Service
This article will build upon our initial SharePoint 2010 install utilizing the least privilege model which I have documented here, so check it out if you haven’t already done so.
Managed Metadata Service
The User Profile service requires that the Managed Metadata Service is setup and configured first before attempting setting up our first User Profile Service.  The Managed Metadata service allows you to utilize managed metadata and provides you with the ability to share content types across sites.  You can read more about Managed Metadata here.
To setup our Managed Metadata Service, navigate to Central Administration / Application Management / Manage Service Applications.
Click New and select “Managed Metadata Service”
Enter the follow details;
Name: Managed Metadata Service
Database Server: <server_name>
Database Name: Managed Metadata DB

I will utilize the sp_farm account for the Application Pool Identity.
image thumb56 Configuring the User Profile Service in SharePoint 2010

Click Create.
Lastly, navigate to Central Administration / System Settings / Manage services on server and start the Managed Metadata Web Service.
image thumb57 Configuring the User Profile Service in SharePoint 2010

User Profile Service
Now that we have successfully configured our Managed Metadata service we can now focus our attention on the User Profile Service.  The User Profile Service provides our SharePoint farm with all the social networking features that we have come to love in SharePoint 2007, plus more.  It forms the basis of My Site support, User profile pages, Audiences and some of the newer features in SharePoint 2010 social computing such as social tagging.
Before we begin, we need to ensure that our Farm account (DOMAIN\sp_farm) is listed as a member of the Local Administrator’s group where the User Profile Synchronization (UPS) service will be deployed.  Please make a note to remove the DOMAIN\sp_farm account from the Local Administrator’s group after provisioning the User Profile Synchronization service.  Please also note, that if you ever have to re-provision the UPS service at a later date, that you will need to ensure the DOMAIN\sp_farm account is added back to the Local Administrator’s group.
Let’s now navigate to Central Administration / Application Management / Manage Service Applications.
Click New and select “User Profile Service Application”
image thumb58 Configuring the User Profile Service in SharePoint 2010

The “Create New User Profile Service Application” window pops up in which you will enter the following details; (you will obviously enter in the details based on your environment setup)
Name: User Profiles
Create new application pool: SharePoint – User Profiles
image thumb59 Configuring the User Profile Service in SharePoint 2010

Register a new managed account: e.g. DOMAIN\sp_userprofiles (nb: this account will need to be provisioned in Active Directory first)
image thumb60 Configuring the User Profile Service in SharePoint 2010
Enter your Profile Database server details and database authentication.  You will notice that SharePoint 2010 introduces the ability to configure Failover Server which allows you to associate your SharePoint databases with another SQL server for failover purposes utilising SQL Server database mirroring.   We will not specify a Failover Database server for any of our databases at this present time.
image thumb61 Configuring the User Profile Service in SharePoint 2010
Specify your Synchronization Database which is used to store configuration and staging data for synchronization of profile data such as that from Active Directory.
image thumb62 Configuring the User Profile Service in SharePoint 2010
Next, specify your Social Tagging Database which is used to store tags and notes that are created by users.  Social Tagging is a new feature in SharePoint 2010 which is not only displayed against the items that user’s are tagging, but are also displayed in the user’s activity feed.
image thumb63 Configuring the User Profile Service in SharePoint 2010

Next, select your Profile Synchronization Instance Server.
In the proceeding section, we will not create a My Site Host URL and will leave this for part two of this series.
Click Create
image thumb64 Configuring the User Profile Service in SharePoint 2010
You should now have the User Profiles service application listed and  started.
image thumb65 Configuring the User Profile Service in SharePoint 2010

We will now venture back into Central Administration / System Settings / Manage services on server.
Scroll down to the User Profile Service and User Profile Synchronisation Service and start both.  The User Profile Service should start without any further user interaction, however the User Profile Synchronization Service will ask for your SharePoint Farm credentials.
image thumb66 Configuring the User Profile Service in SharePoint 2010

Click Ok.
Both services should now be listed as started.
image thumb67 Configuring the User Profile Service in SharePoint 2010
This in turn, will correctly configure and start our ForeFront Identity Manager Windows Services (FIM).
image thumb68 Configuring the User Profile Service in SharePoint 2010

At this point, it is imperative you run an IIS reset.  Even better, just reboot the machine icon smile Configuring the User Profile Service in SharePoint 2010
We will now configure our User Profile Connection to our Active Directory Domain.
Navigate to Central Administration / Application Management / Manage Service Applications.
Click on User Profiles / Manage.
image thumb69 Configuring the User Profile Service in SharePoint 2010

Click on Configure Synchronizations connections / Create New Connection.
Enter the follow details;
Connection Name:
Type: Active Directory
Auto discover domain controller or specify a domain controller
Authentication Provider Type: Windows Authentication
Account Name / Password:
Port: 389
image thumb70 Configuring the User Profile Service in SharePoint 2010
Click on Populate Containers
image thumb71 Configuring the User Profile Service in SharePoint 2010

Click OK.
Your connection should now be listed as follows upon successful creation
image thumb72 Configuring the User Profile Service in SharePoint 2010
image thumb73 Configuring the User Profile Service in SharePoint 2010
Next we will Configure a Synchronization Timer Job via Central Administration / Application Management / Manage Service Applications / User Profiles.
image thumb74 Configuring the User Profile Service in SharePoint 2010

Click Enable
We will finish off by initiating a full synchronization via Central Administration / Application Management / Manage Service Applications / User Profiles / Start Profile Synchronization.
image thumb75 Configuring the User Profile Service in SharePoint 2010
In order to confirm that the import was a success, the Number of User Profiles should now be set to the number of users in your organization, in my case I have 269 dummy users in my Active Directory domain.  Word of note; this will take some time and is considerably slower than an Active Directory User Profile import in SharePoint 2007.
image thumb76 Configuring the User Profile Service in SharePoint 2010
You can also venture into Manage User Profiles and search for users (please take note that SharePoint 2010 does not display any users by default and that you will have to search for them).
image thumb77 Configuring the User Profile Service in SharePoint 2010
Edit a User Profile to ensure that all the necessary Active Directory attributes were successfully imported.
image thumb78 Configuring the User Profile Service in SharePoint 2010

We have now successfully completed a User Profile Synchronization which will form as a basis for User’s My Sites in my next article.  Until then, happy SharePointing!!
References
User Profile Service administration (SharePoint Server 2010) http://technet.microsoft.com/en-us/library/ee721050.aspx
Configure profile synchronization (SharePoint Server 2010) http://technet.microsoft.com/en-us/library/ee721049.aspx













Installing and Configuring Remote BLOB Storage

I’m sure you realize that nothing is perfect. That includes Microsoft SQL Server, and even if
you believe it’s the best database server in the world, it can still get overloaded and crowded
with data. It also doesn’t deal as well with unstructured binary files as it does with structured
data, and a lot of data is unstructured in binary large object (BLOB) files. If only there were
some way of using an external data store to contain those binary data files for SharePoint.
Now there is.
Installing and configuring Remote BLOB Storage (RBS) lets you store your BLOB data
with an EBS provider so that both your structured and unstructured data is being placed
in, housed in, and retrieved from the optimal storage types for those data forms.
This doesn’t mean that you absolutely must use RBS, and you certainly can store your
unstructured data files in SQL, but it’s not the best solution available, particularly if data
access and retrieval is important, and it almost always is. Although setting up RBS may be
more work, it often is worth the effort. If you choose to employ the RBS option, you face
three basic tasks:
1.
Enabling the FILESTREAM and provisioning the RBS data store
2.
Installing the RBS
3.
RBS is a library application programming interface (API). It’s integrated as an add-on
feature for both Microsoft SQL Server 2008 and Microsoft SQL Server 2008 Express and
is designed to move BLOB data stored on database servers to what is called
storage solutions
provider, which uses the RBS APIs to store BLOBs.
This work is done on Microsoft SQL Server, and as a SharePoint administrator, you may
not have a hand in performing the following tasks. However, since this feature is tied directly
to SharePoint Server 2010, the information is presented, and in a small enough company or in
a large company with limited IT resources, you may need to have these skills.
The following tasks require that you belong to the Administrators group for all the web
servers and application servers in the server farm. You must also belong to the dbcreator
and securityadmin fixed server roles on the computer running SQL Server 2008 or SQL
Server 2008 Express.
Enabling the FILESTREAM and Provisioning the RBS Data Store
The first task you must perform is to enable
FILESTREAM on the SQL Server instance:
1.
appears, click Microsoft SQL Server 2008.
On the computer running SQL Server, click Start All Programs; in the list that
2.
Manager.
In the list that appears, click Configuration Tools and then click SQL Server Configuration
3.
and then click Properties.
4.
the Enable FILESTREAM For Transact-SQL Access check box.
In the SQL Server Properties dialog box, click the FILESTREAM tab and then select
5.
the Windows share in the Windows Share Name field if you want to read and write
FILESTREAM data from Windows.
Click Enable FILESTREAM for file I/O streaming access and then enter the name of
6.
remote clients are required to access FILESTREAM data on the share.
Select Allow Remote Clients To Have Streaming Access To FILESTREAM Data if
7.
Click Apply.
8.
Management Studio.
Click Start All Programs Microsoft SQL Server and then select SQL Server
9.
In SQL Server Management Studio, click New Query to open the Query Editor.
10.
In the Query Editor, enter the following and then click Execute:
EXEC sp_configure filestream_access_level, 2
RECONFIGURE[
Now that FILESTREAM is enabled, you need to provision the BLOB store in SQL Server:
1.
step 8 of the previous task and then expand Databases.
On the SQL Server instance, open the SQL Server Management Studio as shown in
2.
New Query.
Select the content database for which you want to create the BLOB store and then click
3.
you see here. You must replace
replace
In the Query pane, enter and execute each of the following SQL queries in the sequence[WSS_Content] with the actual content database name andc:\BLOBStore with the volume/directory where you want the BLOB store created.
In the SQL Server Configuration Manager, locate the desired SQL Server, right-click it,
Enabling and testing the RBScommodityor third-party RBS storage. RBS comes with the RBS FILESTREAM

Deleting a Mobile Account

Deleting a mobile account configured to receive notices from either the server farm or
a web application pretty much involves the same set of steps, and both actions are performed
in Central Administration. To delete a mobile account from a server farm, follow
these steps:
1.
On the Central Administration main page, click System Settings.
2.
Mobile Account.
On the System Settings page, under E‑mail And Text Messages (SMS), click Configure
3.
click OK.
To delete a mobile account from a web application, follow these steps:
On the Mobile Account Settings page, clear all the check boxes present and then
1.
Applications.
In Central Administration, under Application Management, click Manage Web
2.
Open the General Settings menu on the Ribbon and then click Mobile Account.
3.
boxes and then click OK
On the Web application Text Message (SMS) Service Settings page, clear all the check

SharePoint 2010 Backup and Recovery: Configuring Restore

The first part of this mini-series on configuring SharePoint 2010 backup and restore focused on the backup part. This part will introduce the basic setup for performing SharePoint 2010 restores.
In this article, we will address mainly the PowerShell approach, showing that this is the most complete and flexible approach when it comes to restore operations. All the PowerShell restore operations address well the flexible granularity of SharePoint 2010 restores, allowing farm-level, web/service application-level, and site collection/list/library-level restores. However, we will also explore how the SQL Server tools can be used to back up and restore content databases.
But first things first: let’s start with the initial configuration settings for restoring.
Initial Restore Configuration
First, what you need to do is start the SharePoint Foundation Administration Service on all farm servers. This is done through the Microsoft Management Console and the Services snap-in (services.msc).
The Administration Service is vital when it comes to running a SharePoint 2010 environment. It is required for creating and deleting web applications, as well as starting or stopping SharePoint-related services. It must be run on all servers of a SharePoint farm. If it does not run, any operations that deal with backing up and restoring (no matter which granularity level you are working with) might fail either entirely or at least partially.
As a consequence, for troubleshooting failed restore operations, it is usually a good idea to check whether the SharePoint Foundation Administration Service is running on each and every server of the farm. Often enough it is also a good idea to check whether the account running this service is part of the local administrators group. This is an absolute requirement for the service to run correctly.
The following general rules summarize the possibilities of what can and what cannot be restored with SharePoint 2010:
Config and content dattabases cannot be restored with SP2010 utilities.
After a restore with the SP2010 utilities, service applications must be restarted using either Central Administration or PowerShell.
When restoring/reattaching databases, it is best to choose the OVERWRITE option (this will keep the database IDs; hence, database change logs can continue to be used).
BLOB stores can be restored using SharePoint only if FILESTREAM is the blob provider.
Restoring an Entire Farm
There are a number of common scenarios when you might want to restore your entire farm environment to an earlier point in time.
The seldom occurring case is a disaster case, such as severe hardware failure (usually the disks) but also natural disasters, such as floods, fires, and so on. In such a case you might have to restore your SharePoint environment as soon as possible in order to regain your business’s operability. Also, if you want to restore your configuration data to a previous point in time, it is good practice to restore your entire farm environment. Third, if you plan to move to another farm topology, you will have to perform a farm restore. But be aware that a farm restore is not possible from single to multifarm, and vice versa, and it is also not possible between different versions of SharePoint 2010 (for example, switching from SharePoint Server 2010 Standard to the Enterprise edition).
A very straightforward mechanism to restore an entire farm is using PowerShell. The cmdlet Restore-SPFarm permits you to restore an entire farm, specifying nothing but the directory where the backup files are located and the restore method.
1
Restore-SPFarm –Directory "path" –RestoreMethod Overwrite [-BackupId "guid"]
Omitting the optional –BackupId parameter will cause the most recent backup to be taken. If, on the other hand, you would like to restore a specific backup, it is a very good idea if you knew which one to restore. Also for this task, PowerShell brings the proper out-of-the-box support using a dedicated cmdlet, which is called Get-SPBackupHistory.
1
Get-SPBackupHistory -Directory "path"
The previous cmdlet will output a list of all available backups within the specified directory.
Once you are done with the restore of your farm environment, it is an absolute necessity to restart the service applications. As mentioned, please do not use the Products Configuration Wizard, since this would not only restart the services but also reprovision them and therefore overwrite all custom settings for those service applications.
You have two ways of restarting the service applications in a safe manne: one is to manually click Stop in Central Administration for each of the services running on the server and then click Start. Note that some services (such as the User Profile Synchronization service) can take several minutes to start.
A more elegant way of restarting all the services is the PowerShell approach, where you can restart them using only two commands, involving just three different cmdlets. Get-SPServiceInstance retrieves a list of all the provisioned services. Using PowerShell’s piping feature, it is easy to stop all of them by issuing just one command:
1
Get-SPServiceInstance Stop-SPServiceInstance
Afterward, you can restart the services by using the following command:
1
Get-SPServiceInstance Start-SPServiceInstance
This looks straightforward, and it is usually also done within a few minutes, but there is one important thing to keep in mind: between the stopping and restarting of the services, your SharePoint environment is completely down. Even Central Administration will not be accessible.
Restore Using the SQL Server Tools
You do also have the possibility to restore a farm (better: its contents) using the SQL Server tools, namely, the SQL Server Management Studio (SSMS), respectively its Express variant. With this management tool, you can easily expand the Databases node, select the content database you would like, right-click it, and perform backup and restore tasks (All tasks Backup resp. Restore).
Using SSMS, you can easily perform a backup and restore on database levels. However, there are a few limitations to this approach:
You cannot restore the SharePoint 2010 configuration data.
You cannot restore SharePoint 2010 search.
There are a number of scenarios when adopting SSMS for a restore is considered a good practice:
Restoring the most recent full DB backup
Restoring the most recent differential DB backup
Restoring transaction log backups
After performing the actual backup and/or restore, you need to carry out a number of tasks; since SSMS is not capable of restoring configuration data, you need to restore this manually (ideally using PowerShell) and then restart all the services in order to ensure that the configuration data is used.
Restore the configuration database using Central Administration or PowerShell (PS: Restore-SPFarm -ConfigurationOnly).
Restart SharePoint Services Timer Services.
Restart the service applications (see the earlier section on how to restart all services).
Using SSMS is usually a quick means of reestablishing a previous content database state without a lot of effort. The only things to keep in mind are the post-restore actions mentioned earlier.
Backing Up and Restoring Configuration Settings on Another Farm
There are situations where you might want to back up your farm environment and rebuild it on another environment, such as when creating a test farm from an existing production farm. In such a case, you do not necessarily need the content databases. This makes backing up and restoring it a lot easier, since you need to copy and restore a lot fewer databases.
What you need to bear in mind for the mentioned scenario is that you must copy and restore the configuration settings for the following elements:
The farm
Web applications
Service applications
On the web application level, it is a good starting point to obtain a list of all the web applications and their content databases. The following command will output such a list:
1
Get-SPWebApplication %{$_.Name;$_.Url;%{$_.ContentDatabases%{$_.Name}; Write-Host “” }}
This way, you can further filter using WHERE for specific web applications. However, when reproducing a production environment on test, the usual case is that you want to have all your web applications present also on the test environment.
The next step consists of detaching all content databases from their web applications. Please schedule downtimes thoroughly beforehand, since this will stop all web applications from working properly. The following command will disconnect all content databases from their corresponding web applications so you can back up only their configuration settings.
1
Get-SPContentDatabase Dismount-ContentDatabases
This was already the tough part of saving configuration settings. With the known Backup-SPFarm cmdlet, you can simply back up the whole farm, not including the content databases.
1
Backup-SPFarm –Directory "path" -BackupMethod "Full Differential"
After backing up to the specified directory, it is about time you reattach the content databases to their respective web applications. For this purpose, you can reuse the list obtained using Get-SPWebApplication, combining web application names with their corresponding content databases.
The Mount-SPContentDatabase cmdlet, which takes the name of the content database as well as the respective web applications as parameters, performs this task.
1
Mount-SPContentDatabase –Name "WSS_Content" -WebApplication "URL"
So far, so good. Up to now, you carried out all tasks only on the base (production) machine, where you prepared all the backup of the configuration settings. It’s time to move on to the test environment.
You can make the backup files accessible to the test system either by using a share (recommended) or by copying the backup files to your new test system. Obviously, the latter approach is more time-consuming.
On the test system, you need to issue the already known Restore-SPFarm cmdlet, with one exception: this time, you will have to append the -ConfigurationOnly flag, which will tell the cmdlet that you are trying to restore only the configuration data settings, not the content databases. Issue the command as follows:
1
Restore-SPFarm –Directory "path" -RestoreMethod Overwrite -ConfigurationOnly
Using the same cmdlet, adding the parameter -Item, you can restore a single web or service application’s configuration settings. The same is valid also for restoring search applications and the Secure Store service (which is not possible using the SSMS restore approach).
1
Restore-SPFarm –Directory -RestoreMethod Overwrite –ConfigurationOnly –Item "web app service app"
However, additional tasks are required in order to fully restore the Secure Store service (SSS). If you do not perform these tasks, expect the SSS and all other service applications that depend on it to fail with corresponding exceptions, stating a problem with the used key.
The solution to this is quite simple: you have to update the SSS key, specifying the passphrase that you should have saved (or memorized) during the provisioning of the Secure Store service. This can be done using the Update-SPSecureStoreApplicationServerKey cmdlet:
1
Update-SPSecureStoreApplicationServerKey –Passphrase
PowerShell can also restore content databases; as a matter of fact, it is the only way of restoring read-only databases. Please note that restoring read-only databases will make them read-write automatically. Here is the command for the task:
1
Mount-SPContentDatabase –Name -WebApplication
Restoring Site Collections, Lists, and Libraries
Similar to the backup, the restore functionality of SharePoint 2010 offers a lot of granularity. Top-down, you can restore from the farm level through the web/service application level to the single list/document library/site collection level. Instead of Restore-SPFarm, Restore-SPSite is used for restoring site collection.
If your site collection exceeds 1GB in size, it is generally considered good practice to use the -GradualDelete parameter, which will greatly reduce the workload imposed by this operation.
1
Restore-SPSite –Identity "SiteCollection URL" -Path "path" [-DatabaseServer "server"] [-DatabaseName "database"] [-GradualDelete]
Restore-SPSite allows you also to change the database for an existing site collection and even the database server. This operation is supported only when performing a restore using PowerShell.Similarly, you can restore lists and libraries, using the Import-SPWeb cmdlet. The only two parameters that you need to specify are the name of the site where to restore your list/library and the path where the file resides. It’s as simple as that.
1
Import-SPWeb –Identity "URL" -Path "path"
Both tasks can be carried out also using Central Administration, specifically under Backup and Restore Farm Backup and Restore Restore a farm.
Conclusion
SharePoint 2010 offers a great level of flexibility and granularity when it comes to backing up and restoring whole farms or just single lists. This flexibility is once more underlined by the different methods that you can adopt for performing restores: Central Administration, PowerShell, or the SQL Server tools.
Although the first approach is certainly the easiest, especially for SharePoint 2010 beginners, you will probably soon recognize the benefits from adopting PowerShell. All restore operations can be performed also by using PowerShell, often offering additional functionality (such as changing the database and database server when restoring site collections). Plus, PowerShell offers the ability to automate many tasks, for example restarting all services at once, which is functionality missing in Central Administration. So, for daily use, the higher initial effort to learn the PowerShell approach soon pays off by offering automation and additional functionality.
The SQL Server tools approach is certainly not the most complete, but for performing quick restores of content databases, it can be the tool of choice. Usually, it is best to choose your tools according to your needs as a SharePoint 2010 administrator.
This concludes this second part of the mini-series about backing up and restoring SharePoint 2010 environments, focusing on PowerShell and different granularity. I hope you’ve enjoyed the ride and learned something you didn’t know before. Feel free to leave comments if you have questions or suggestions.