Friday 28 September 2012

Back up a site collection in SharePoint Server 2010



Use Windows PowerShell to back up a site collection in SharePoint Server
You can use Windows PowerShell to back up a site collection manually or as part of a script that can be run at scheduled intervals.
To back up a site collection by using Windows PowerShell
  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.
  2. On the Start menu, click All Programs.
  3. Click Microsoft SharePoint 2010 Products.
  4. Click SharePoint 2010 Management Shell.
  5. At the Windows PowerShell command prompt type the following command:
PowerShell
Backup-SPSite -Identity <Site collection name> -Path <backup file> [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]
Backup Steps
1. Navigate to the Central Administration => Backup and Restore
2. Under “Farm Backup and Restore” section click “Perform a backup”.
3. Now you’ll be landed in the following page where you can select the site or site collection you want to take backup:




4. Click next and you’ll be navigated to the following page where you can select backup type (full or differential) and backup location:
Restoring Steps
To restore follow the steps:
1. Navigate to the Central Administration => Backup and Restore.
2. Under “Farm Backup and Restore” section click “Restore from a backup”. Follow the wizard to restore from a backup.

Backup/Restore from one server to another or from one Site Collection to another (with PowerShell command)

In some cases, you have developed a SharePoint site collection in your dev or stg machine and now you want to move the site with data from dev/stg to production. In such cases the process shown in the section “Backup/Restore in the same server and same site  collection” will not work. The recommended way is to use PowerShell command to take backup and restore the backup.
Backup a Site collection with PowerShell command
In SharePoint 2010, PowerShell command Backup-SPSite is used for taking backup. you can get details of the command from the msdn link. The following command will backup the site collection ‘http://myserver’.
Backup-SPSite -Identity http://myserver -Path "c:\backup\file.bak"
Restore a Site Collection with PowerShell command
To restore site collection you’ll use the following command. Use –Force if you want to overwrite the existing site collection
Restore-SPSite -Identity http://myserver -Path "c:\backup\file.bak"
However, once I had restored the backup I could not access the site. The problem was that I needed to deploy the custom SharePoint solution. So in case of site collection migration (with backup/restore) from one server to another or from one site collection to another, the steps should be:
1.    Restore the backup.
2.    If your source site collection (from where you taken backup) uses custom SharePoint solution, then deploy the solution in the destination site collection (where you are restoring the backup). If you try to access the site without deploying solution then you may get the site non-functional.
3.    Now you can try to access the site.

Back up a farm (SharePoint 2010)




Use Windows PowerShell to back up a farm in SharePoint
You can use Windows PowerShell to back up the farm manually or as part of a script that can be run at scheduled intervals.
To back up a farm by using Windows PowerShell
  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.
  2. On the Start menu, click All Programs.
  3. Click Microsoft SharePoint 2010 Products.
  4. Click SharePoint 2010 Management Shell.
  5. At the Windows PowerShell command prompt, type the following command:
Backup-SPFarm -Directory <BackupFolder> -BackupMethod {Full | Differential} [-Verbose]

Use Central Administration to back up a farm

You can use Central Administration to back up the farm.

To back up a farm by using Central Administration

1.       To perform this procedure, you must be a member of the Farm Administrators group on the computer that is running Central Administration.
2.       In Central Administration, on the Home page, in the Backup and Restore section, click Perform a backup.
3.       On the Perform a Backup — Step 1 of 2: Select Component to Back Up page, select the farm from the list of components, and then click Next.
4.       On the Start Backup — Step 2 of 2: Select Backup Options page, in the Backup Type section, select either Full or Differential.
5.       In the Back Up Only Configuration Settings section, click Back up content and configuration settings.
6.       In the Backup File Location section, type the UNC path of the backup folder, and then click Start Backup.
7.       You can view the general status of all backup jobs at the top of the Backup and Restore Status page in the Readiness section. You can view the status for the current backup job in the lower part of the page in theBackup section. The status page updates every 30 seconds automatically. You can manually update the status details by clicking Refresh. Backup and recovery are Timer service jobs. Therefore, it may take several seconds for the backup to start.
If you receive any errors, you can review them in the Failure Message column of the Backup and Restore Job Status page. You can also find more details in the Spbackup.log file at the UNC path that you specified in step 6.

Use SQL Server tools to back up a farm

If you want to back up the complete farm, you must use either Windows PowerShell or Central Administration. You cannot back up the complete farm by using the SQL Server tools because you cannot use the tools to back up the farm’s configuration. However, you can back up all the databases that are associated with the farm.

To back up the databases associated with a farm by using SQL Server tools

1.       To use SQL Server tools to back up SharePoint Foundation 2010 databases, the account that is used to back up the databases must be a member of the SQL Server db_backupoperator fixed database role on the database server where each database is stored.
2.       Open SQL Server Management Studio and connect to the database server.
3.       In Object Explorer, expand Databases.
4.       Right-click the database that you want to back up, point to Tasks, and then click Back Up.
5.       In the Back Up Database dialog box, in the Source area, select the kind of backup that you want to perform from the Backup type list. For more information about which backup type to use, see Overview of Recovery Models (http://go.microsoft.com/fwlink/p/?LinkId=114396).
6.       In the Backup component area, click Database.
7.       Either use the default name provided or specify a name for the backup set in the Name text box.
8.       Specify the expiration date for the backup set. This date determines how long, or when, the backup set can be overwritten by any later backups that have the same name. By default, the backup set is set to never expire (0 days).
9.       In the Destination area, specify where you want to store the backup.
10.    Click OK to back up the database.
11.    Repeat steps 1-10 for each farm database.

Deploy SharePoint 2010 solution(.wsp) package using Powershell

Deploy SharePoint 2010 solution(.wsp) package using Powershell

In this article we will discuss how to deploy the SharePoint 2010 solution package (.wsp) using PowerShell

Step1:  Start Power Shell command prompt
Start->All Programs->MicrosoftSharepoint2010Products->open Sharepoint2010Managementshell

Type the command

Step2:  Add Solution Package
Add-SPSolution “C:\SharePoint2010Solution.wsp”

Step3:  Install Solution Package
Install-SPSolution –Identity SharePoint2010Solution.wsp –WebApplication http://myserver –GACDeployment

If you are using Sandbox Solution,

Step4: Install Solution Package
Install-SPUserSolution –Identity SharePoint2010Solution.wsp     –WebApplication http://myserver  –GACDeployment

For Updating the Sharepoint 2010 Solution type the following commands

Step5: Update Solution Package
Update-SPSolution –Identity SharePoint2010Solution.wsp –LiteralPath “C:\SharePoint2010Solution.wsp” –GacDeployment

For retract and remove a solution, type the following commands:

Step 6: Uninstall Solution Package
Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication    http://myserver

Step7: Remove Solution Package
Remove-SPSolution–Identity MySharePointSolution.wsp