Skype for Business 2015 – Automated Backup Script

A few years ago I created a Lync 2013 backup script that would backup data from all servers in the Topology. Lync 2013 Automated Backup Script

This script also works with Skype for Business 2015 but it specifically backed up Response Group and User data by identifying the pool version.  The script below has been updated and tested on SfB 2015.

<#
Author:  Chris Hayward, chrishayward.co.uk
Purpose: Centralised script to backup Lync 2013 and SfB 2015
Version: 1.2
Changes: DATE - Change
        06/11/2013 - Release 1.1 - Fixed code that deletes old backup directories (CH)
        27/11/2015 - 1.2 Updated for Skype for Business (version -gt 7 rather than -eq 6)
#>
 
Import-Module Lync
 
# Script Config
$BackupPath = "D:\_Backup\" # Backup Path
$BackupRetention = -14 # Number of days to keep old backups (Requires a "-", e.g. two weeks would be -14, 5 days would be -5)
 
# *** Start of script ***
 
# Delete old backup directories
Get-ChildItem $BackupPath |? {$_.psiscontainer -and $_.lastwritetime -le (get-date).adddays($BackupRetention)} |% {remove-item $_.FullName -recurse -force}
 
# Get date in day-month-year format and set backup path
$DateStamp = Get-Date -Format dd-MM-yy
$BackupPath = $BackupPath + "LyncBackup_" + $DateStamp +"\"
New-Item $BackupPath -type directory -force
 
# Backup the Lync Central Management Store
$CMSBackupFile = $BackupPath + "Lync-CMS-Config.zip"
Export-CsConfiguration -FileName $CMSBackupFile
 
# Backup Location Information Service data
$LISBackupFile = $BackupPath + "Lync-LIS-Config.zip"
Export-CsLisConfiguration -FileName $LISBackupFile
 
# Backup User Data (Lync 2013 & SfB 2015 servers only)
$UserServer = Get-CsService -UserServer | Where-Object {$_.version -ge 6}
 
ForEach ($Service in $UserServer) {
    $UserDataBackupFile = $BackupPath + "Lync-User-Config_" + $($Service.PoolFqdn) + ".zip"
    Export-CsUserData -PoolFQDN $($Service.PoolFqdn) -FileName $UserDataBackupFile
}
 
# Backup Response Group Configuration (Lync 2013 & SfB 2015 servers only)
$ApplicationServer = Get-CsService -ApplicationServer | Where-Object {$_.version -ge 6}
 
ForEach ($Service in $ApplicationServer) {
    $RGSBackupFile = $BackupPath + "Lync-RGS-Config_" + $($Service.PoolFqdn) + ".zip"
    Export-CsRgsConfiguration -Source ApplicationServer:$($Service.PoolFqdn) -FileName $RGSBackupFile
}
 
# Backup Voice Configuration
$BackupPath = $BackupPath + "Lync-Voice-Config\"
New-Item $BackupPath -type directory -force
 
Get-CsDialPlan | Export-Clixml -path $BackupPath\DialPlan.xml
Get-CsVoicePolicy | Export-Clixml -path $BackupPath\VoicePolicy.xml
Get-CsVoiceRoute | Export-Clixml -path $BackupPath\VoiceRoute.xml
Get-CsPstnUsage | Export-Clixml -path $BackupPath\PSTNUsage.xml
Get-CsVoiceConfiguration | Export-Clixml -path $BackupPath\VoiceConfiguration.xml
Get-CsTrunkConfiguration | Export-Clixml -path $BackupPath\TrunkConfiguration.xml

 

To run the script as a scheduled task:

  1. Create a service account and add it to the RTCUniversalServerAdmins AD group (e.g. svclyncbackup)
  2. Copy the above PowerShell script to one of your SfB servers (e.g. Front End 1 C:\Tasks\SfB-Backup.ps1)
  3. Create a scheduled task to run daily (e.g. 3am)
  4. Create an Action > Start a Program > Program=powershell.exe > Arguments=C:\Tasks\SfB-Backup.ps1

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.