his 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.

# Author:   Created by Shy IT, www.ShyIT.co.uk
# Purpose:  Script to backup Lync 2013
# Version:  1.0
# Changes:  DATE - Change
#           08/07/2013 - Release 1.0
        
Import-Module Lync
        
# Script Config
$BackupPath = "C:\LyncBackups\Backups\" # 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 $_ -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 $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


link:http://shyit.wordpress.com/2013/07/07/lync-2013-automated-backup-script/