{%Pragmatic Coding%} Tips and tricks for software developers.

25Jul/120

SharePoint 2010: Simple Backup/Restore via PowerShell

Hello dear readers!

In this article I will show you the main simple samples of backing up and restoring SharePoint SPFarm and SPSite in Windows PowerShell.

Backup-SPFarm
Creates a backup of an individual database, Web application, or the entire farm.

Required params:

BackupMethod (System.String) - Specifies the type of backup file to be created. A full backup is a backup of all the selected data. A differential backup is a backup of all the selected data that has changed since the last full backup. If an item does not support differential backup, then a full backup is performed for that item instead. The type must be either of the following:
- Full
- Differential

Directory (System.String) - Specifies the path where SharePoint 2010 Products stores the backup package it generates. If you have a computer on which Microsoft SQL Server 2008 and an instance of SharePoint 2010 Products are installed, you can use local drive paths.

Examples:

This example backs up the configuration settings of the farm to the \\file_server\share\Backup directory.

This example backs up the configuration settings of the farm to the C:\\Backup directory.

Restore-SPFarm
Restores one or more items from a backup.

Required params: no required fields.

Examples:

This example restores the configuration settings from the backup package in the \\file_server\share\Backup directory to the farm.

This example show which components of the farm would be restored under the Microsoft SharePoint Foundation Web Application node, but does not actually restore them.

This example restores a farm by using 10 threads and suppresses the overwrite warning.

For more details, please, visit Backup-SPFarm and Restore-SPFarm.

Backup-SPSite
Performs a backup of a site collection.

Required params:
Identity (Microsoft.SharePoint.PowerShell.SPSitePipeBind) - Specifies the URL or GUID of the site collection to be backed up. For example, a valid URL, such as http://server_name/sites/site_name or a GUID such as, "01234567-89ab-cdef-0123-456789abcdef"
Path (System.String) - Specifies the full path to the backup file (that is, C:\Backup\site_name.bak.

Examples:

This example backs up a site collection at http://server_name/sites/site_name to the C:\Backup\site_name.bak file.

This example backs up a site collection at http://server_name/sites/site_name to the C:\Backup\site_name.bak file. Same result as Example 1, but a different way of performing the operation.

This example backs up a site collection using database snapshots to ensure backup integrity.

Restore-SPSite
Restores a site collection.

Required params:
Identity (System.String) - Specifies the URL location to which the site collection is restored. A site collection does not have to already exist at the URL location to perform a restore. However, you must specify a valid URL location that a site collection can be created. If a site collection already exists at the specified URL location, you must specify the Force parameter to overwrite it.The type must be a valid URL, in the form http://server_name/sites/site_name.
Path (System.String) - Specifies the full path to the backup file (that is, C:\Backup\site_name.bak.

Examples:

This example restores a site collection from the backup file C:\Backup\site_name.bak to the site collection URL http://server_name/sites/site_name.

This example restores a site collection backup from the backup file C:\Backup\site_name.bak, but overwrites the existing site collection at http://server_name/sites/site_name while specifying that the site collection must be stored in a specific content database.

This example restores a site collection backup from the backup file \\file_server\share\site_name.bak to the host-named site collection http://www.example.com on the Web application http://server_name.

For more details on how to Backup/Restore SPSite, please, visit Backup-SPSite and Restore-SPSite.

Share on social network

Share to Facebook
Share to Google Plus
Share to LiveJournal
Share to MyWorld
Share to Odnoklassniki
Share to Yandex
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.