PowerShell Script To Backup Multiple Site Collections In A Single Go

Table of Contents

  1. Objective 4
  2. Business Case 4
  3. Targeted Audience 4
  4. Offerings 4
  5. Technical Details 4
    5.1 Pre-requisites 4
    5.2 Execution 5
    5.3 Output Folder 6
  6. Powershell Script 6
  1. Objective

    This purpose of this document is to mentions the steps to take a backup of multiple site collections in a single go using PowerShell script. The reusable script for this job has also attached with this document. This script offers:

    • To read a set of site collections, for which backup is needed, from a configurable XML file.
    • Backup generation of the site collections provided in the configurable XML file.
     
  2. Business Case

    S. No. Business Case
    1 For several reasons (Some application release, Deployment, Migration etc.) SharePoint Support team requires multiple site collection backup. Doing this one by one is a painful job for administrator. This script will allow administrator to do the job just by configuring the XML file.

  3. Targeted Audience

    • SharePoint Application Developers
    • SharePoint Administrator
    • SharePoint Architect

  4. Offerings

    • One reusable PowerShell script is provided which needs to be run to generate backup
    • Format of XML file is provided where site collection needs to be configured.
    • After running the script backup file will get generated in following format:
    1. <WebApplicationURL>_<ManagedPath>_<SiteTitle><yyyymmdd>_<TimeStamp>  
    For example, If Site collection URL is filename format will be like WebApplication_Sites_SharePoint20150622_083857

  5. Technical Details

    Below are the technical details for this PowerShell script,

    5.1 Pre-requisites

    1. Login to server with Farm administrator account and copy the folder and paste the same to the location where you want to keep it.

    2. Open the folder and Configure XML file as per your requirement.

    code

    As shown in below image; enter Web Application URL at https://myWebApplicationURL and configure a set of Site collection relative URL which you want to backup as shown in above image.

    Note: Name the file as Configuration.xml only.

    5.2 Execution

    Prerequisite:

    Login to SharePoint Server as Farm Administrator and copy the required files (PowerShell script and configuration XML). Configure the XML file as per your requirement.

    Run:

    1. Run the PowerShell Script as “Run as Administrator“

    2. Browse the folder path where you have kept this PowerShell script file and execute a command as shown in below image.

    code

    Note:

    1. As shown in above image; Script will ask you for a path where you want to keep these backup files.
    2. In case you have typed site collection URL wrongly this script will show you an error in red color asking you to check if you have typed the URL correctly.

    error

    5.3 Output Folder

    1. Please find below folder location which we have configured in our script to maintain a site collection backup output location.

    output

    _logs: Folder containing a log file which will maintain an execution log. A filename for a log file will be like <yyyymmdd>_<hhmmss>.

    For example: 20150622_054844.log

  6. PowerShell Script

     BackUpMultipleSiteCollections.PS1folder 

Read more articles on PowerShell:


Similar Articles