Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

SharePoint 2010 Command Line Backup and Restore: Granular Backup and Restore via PowerShell

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
5/22/2011 4:54:51 PM
Export-SPWeb

The Export-SPWeb cmdlet exports the contents of a web or list within a web to one or more files, as shown in the example that follows:

Export-SPWeb - Identity http://foo/sites/bar/site1 -Path c:\backups\site1.cmp


If you want to script a call of Export-SPWeb, especially if you want to protect multiple webs at once, the approach you’ll be most likely to take is going to be similar to what we’ve outlined previously in the section on Backup-SPSite. The difference is that you’re not quite done once you’ve arrived at one or more target site collections; you still need to select the desired webs within those site collections with the Get-SPWeb cmdlet. Once you’ve selected the correct webs with Get-SPWeb, you can pass that array of webs to Export-SPWeb for a granular backup. Following is an example of how to accomplish this:
Get-SPWebApplication -identity $URL | Get-SPSite -filter {$_.Owner = $siteOwner} | Get-
SPWeb | Export-SPWeb -path $backupStorage



The items in the list that follow describe the various parameters that can be used to call Export-SPWeb to export or create a granular backup of a SharePoint site, one or all of its subsites, or a list within a site:

  • Identity. When you export a web or a list within a web, this parameter is required and must be a valid URL or GUID for the target item.

  • Path. When you export a web or a list within a web, this parameter is required and must be a valid UNC or Windows directory path to a file that the backup is saved in. The account logged into the SharePoint 2010 Management Shell must have permission to write to the directory specified for this input.

  • AssignmentCollection. This is an optional parameter, intended to allow for the proper disposal of objects. Carefully consider using this parameter if your call of Export-SPWeb also involves using SharePoint’s SPWeb, SPSite, or SPSiteAdministration objects; otherwise, it is not likely to be necessary.

  • CompressionSize. This parameter is not required. If used, it indicates the maximum size that the compressed export files are allowed to be created to and allows you to set a preferred target size for the CAB files (typically saved as files with a .cmp extension) created by the operation. If the total size of the export is greater than that amount, it is automatically broken into multiple files.

  • Confirm. This is an optional parameter. If this parameter is used with an input value of True, the cmdlet prompts the user to confirm that he wants to proceed with the action. If a value of False is provided, the cmdlet proceeds without prompting for permission once executed. The default value for this parameter is False.

  • Force. This is an optional parameter that does not actually require an input value to be provided for it. If this switch is not used, the cmdlet does not proceed with the backup operation if it estimates that there is not enough disk space available to store the backup. If it is used, that check is overridden, and the backup is executed regardless of how much storage is available.

  • Item. This parameter is not required. It sets the URL of the Web application, GUID, or object to be exported and must be a valid SharePoint URL within the farm. When using this parameter, the full address of the target item is not required. For example, if you are targeting the subsite bar within the http://foo site collection, you would provide /bar for this parameter. Targeting the Calendar list within that bar subsite would be /bar/Lists/Calendar. Of course, you could also use the GUID for each of these items to specify them.

  • HaltOnError. This input parameter is not required; if it is included, the export process is stopped and not completed if errors are encountered.

  • HaltOnWarning. This input parameter is not required; if it is included, the export process is stopped and not completed if warnings are encountered.

  • IncludeUserSecurity. This input parameter is not required; if it is included, the export process includes the user security settings of the targeted item in the export files.

  • IncludeVersions. This input parameter is not required; if it is included, the export process includes the versioning data of the targeted item in the export files based on the type of file or list item history provided as a parameter. If no value is provided for this parameter, a default value of 1 is used to export the target’s last major version, which can also be targeted with a value of LastMajor. You can use this parameter to target the most current version (major or minor) using a value of CurrentVersion or 2, both the last major and minor versions for the item with a value of LastMajorandMinor or 3, or all versions for the targeted item with a value of All or 4.

  • NoFileCompression. This input parameter is not required; if it is included, the export process does not compress the export files it creates. Using this parameter does create a simple problem if you do not direct the export to its own directory. Because the files are not compressed, they are not contained in a CAB file. For performance reasons, Microsoft recommends compressing the export files; their research shows that compression reduces the completion time for export processes by up to 30 percent. If this parameter is used during an export operation, it must also be used during an import operation using the export files it creates.

  • NoLogFile. This input parameter is not required; if it is included, the export process does not create a log file for the export process. It should only be used to improve performance of the export process in extreme conditions; in most circumstances, a log file is desired for export operations.

  • UseSQLSnapshot. This input parameter is not required; when you use it, Export-SPWeb creates a SQL Server database snapshot of the content database containing the targeted item. The export is created by referencing the snapshot rather than the database. Once the export is completed, the cmdlet deletes the database snapshot. You can only use this parameter if your SQL Server instance supports the creation of database snapshots. That’s why it is important to review your SQL Server edition prior to using it. If your instance does support snapshots, this parameter is recommended because, unlike Backup-SPSite, the targeted site collection is not automatically locked during the operation. Unless you manually take action to set the target to read only, your users can modify it during the export process. Because the cmdlet is reading from the snapshot and not the database, there is a drastically reduced chance of resource contention between it and the activities of your users.

  • WhatIf. This is an optional parameter. If you use this parameter, PowerShell displays a message stating what the outcome of running the cmdlet will be, but the cmdlet itself is not executed. This can be helpful when testing scripts, allowing you to verify that you can provide the correct set of inputs and parameters to the cmdlet.

Tip

There are several other SharePoint 2010 cmdlets designed to export data out of a specific area of aspect of a farm that you may want to evaluate and test for use within your farm. Many of these cmdlets are intended to protect specific service applications or functionality that is available only in SharePoint Server 2010, which can limit their scope and usefulness depending on what version of SharePoint 2010 you’re using and what you’ve chosen to implement and enable within your farm. These cmdlets include, but are not limited to, Export-SPBusinessDataCatalogModel, Export-SPBusinessDataCatalogPartitionData,Export-SPEnterpriseSearchTopology, Export-SPInfoPathAdministration-Files, Export-SPMetadataWebServicePartitionData, Export-SPProfileService-ApplicationTenant, and Export-SPSiteSubscriptionSettings.


Import-SPWeb

Import-SPWeb is the flip side of the Export-SPWeb’s coin; it imports the contents of exports created with Export-SPWeb back into a SharePoint 2010 environment. The example that follows shows an import operation that imports both the content and the version data contained in the export file and overwrites any SharePoint content already existing in the target location:

Import-SPWeb -Identity http://foo/sites/bar/site1 -Path c:\backups\site1.cmp
-UpdateVersions -Overwrite


The items in the following list describe the various parameters that can be used to call Import-SPWeb to import or restore a granular backup of a SharePoint subsite or list:
  • Identity. When you import a web or a list within a web, this parameter is required and must be a valid URL or GUID for the target item that the export is imported into.

  • Path. When you import a web or a list within a web, this parameter is required and must be a valid UNC or Windows directory path to the file or files to be imported. The account logged into the SharePoint 2010 Management Shell must have permission to read to the directory specified for this input.

  • AssignmentCollection. This is an optional parameter, intended to allow for the proper disposal of objects. Carefully consider using this parameter if your call of Import-SPWeb also involves using SharePoint’s SPWeb, SPSite, or SPSiteAdministration objects; otherwise, it is not likely to be necessary.

  • ActivateSolutions. This parameter is not required. If used, it indicates that any user solutions should be activated as part of the import process.

  • Confirm. This is an optional parameter. If this parameter is used with an input value of True, the cmdlet prompts the user to confirm that he wants to proceed with the action. If a value of False is provided, the cmdlet proceeds without prompting for permission once executed. The default value for this parameter is False.

  • Force. This is an optional parameter that does not actually require an input value to be provided for it. Using it instructs Import-SPWeb to overwrite any existing item matching the value of the Identity parameter.

  • HaltOnError. This input parameter is not required; if it is included, the import process is stopped and not completed if errors are encountered.

  • HaltOnWarning. This input parameter is not required; if it is included, the import process is stopped and not completed if warnings are encountered.

  • IncludeUserCustomAction. This input parameter is not required; if it is included, the import process includes the user custom actions of the targeted item in the import files.

  • IncludeUserSecurity. This input parameter is not required; if it is included, the import process includes the user security settings of the targeted item in the import files.

  • UpdateVersions. This input parameter is not required; if it is included, the import process uses it to determine how version data in the imported file is integrated into existing versions in the target item. If no value is provided for this parameter, a default value of 1 is used to import the version data as a new version, which can also be accomplished with a value of Append. You can also use this parameter to overwrite the target item with a value of Overwrite and all its existing versions with the newly imported item, or you can ignore any existing files in the targeted location with a value of Ignore.

  • NoFileCompression. This input parameter is not required; if it is included, the import process does not compress the import files it creates. For performance reasons, Microsoft recommends compressing the import files. Their research shows that it reduces the completion time for import processes by up to 30 percent. If you use this parameter during an export operation, you must also use it during any import operation using the export files it creates.

  • NoLogFile. This input parameter is not required; if it is included, the import process does not create a log file for the import process. It should only be used to improve performance of the import process in extreme conditions; in most circumstances, a log file is desired for import operations.

  • WhatIf. This is an optional parameter. If you use this parameter, PowerShell displays a message stating what the outcome of running the cmdlet will be, but the cmdlet is not executed. This can be helpful when testing scripts, allowing you to verify that you can provide the correct set of inputs and parameters to the cmdlet.

Tip

Just like Export-SPWeb, there are several other SharePoint 2010 cmdlets that can import previously exported data into a specific area of aspect of a farm that you may want to evaluate and test for use within your farm. These cmdlets include, but are not limited to, Import-SPBusinessDataCatalogModel, Import-SPBusinessDataCatalogPartitionData,Import-SPEnterpriseSearchTopology, Import-SPInfoPathAdministrationFiles,Import-SPMetadataWebServicePartitionData, Import-SPProfileServiceApplicationTenant, and Import-SPSiteSubscriptionSettings.

Other -----------------
- SharePoint 2010 Command Line Backup and Restore: Reviewing Your Backup and Restore History
- Windows Server 2008 : Choosing Server Roles
- Windows Server 2008 : Overview of Site and Replication Topology
- Windows Server 2008 : Overview of Physical Requirements and Physical Topology
- Windows Server 2008 : Overview of Forest and Domain Trust Models
- Exchange Server 2010 : Managing Records (part 2) - Administrating Managed Folders
- Exchange Server 2010 : Managing Records (part 1) - Using MRM & Configuring Retention Tags and Retention Policies
- Windows Server 2008 : Designing an Active Directory Domain Structure
- Windows Server 2008 : Designing a Forest Structure
- Using SharePoint 2010’s Catastrophic Restore Cmdlets
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server