Lync 2013 – Automated Backup Script

This script will backup Lync 2013 core data and settings off all servers in the topology as per Technet article: http://technet.microsoft.com/en-us/library/hh202170.aspx

The script does the following:

  1. Backup the Central Management Store
  2. Backup the Location Information Service Data
  3. Backup the user data on each Front End pool
  4. Backup the Response Group configuration on each Front End pool
  5. Backup the Voice Configuration

It will create a new folder with a date stamp for each backup.  It will also clean up backups older than x days.  To use the script:

  1. Create a scheduled task on one of your Lync Front End servers to run the backup script, see here.
  2. Configure the Backup Path and Backup Retention values.

Note I have only tested this on Lync 2013 with two standard edition (pool pair) servers.  I have not tested on enterprise pools.  You will also need to do a separate SQL backup of Monitoring, Archiving and Persistent Chat databases as well as a file system backup of all File Stores.  Use at your own risk.

Update 06-11-2013 – I have fixed the delete old backup directories as I noticed that was not working.  Also tested on Lync 2013 Enterprise and seems to work OK :).

# Author: Created by Weakest Lync, www.WeakestLync.com
# Purpose: Script to backup Lync 2013
# Version: 1.1
# Changes: DATE - Change
# 08/07/2013 - Release 1.0
# 06/11/2013 - Release 1.1 - Fixed code that deletes old backup directories

Import-Module Lync

# Script Config
$BackupPath = "C:LyncBackupsBackups" # 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 servers only)
$UserServer = Get-CsService -UserServer | Where-Object {$_.version -eq 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 servers only)
$ApplicationServer = Get-CsService -ApplicationServer | Where-Object {$_.version -eq 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 $BackupPathDialPlan.xml
Get-CsVoicePolicy | Export-Clixml -path $BackupPathVoicePolicy.xml
Get-CsVoiceRoute | Export-Clixml -path $BackupPathVoiceRoute.xml
Get-CsPstnUsage | Export-Clixml -path $BackupPathPSTNUsage.xml
Get-CsVoiceConfiguration | Export-Clixml -path $BackupPathVoiceConfiguration.xml
Get-CsTrunkConfiguration | Export-Clixml -path $BackupPathTrunkConfiguration.xml

 

5 Replies to “Lync 2013 – Automated Backup Script”

  1. Hi Chris,

    This looks like a great piece or work however, I am getting a unexpected token error in the expression for line 18 and 21?

    Any ideas mate.

    Thanks

  2. great script but mune keeps failing because i dont have response groups. any way to get around it and allow the script to finish??

  3. Pingback: Skype for Business 2015 – Automated Backup Script | ChrisHayward.co.uk

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.