Automating Lync 2010 Backups
The backup procedure for Microsoft Lync Server 2010 can be a little daunting as the process is extremely manual. When working with clients I typically deploy a scheduled task on a front-end server to help automate where possible. Backups of SQL (either with a SQL aware backup program or locally to disk) and of the Lync Share are still required as well but at least this covers the rest of the items.
The script is simple but two part – it starts in the command prompt and then calls out PowerShell modules and a PowerShell script to wrap things up. Some manual purging of previous backups is done first and then the current backups are performed (where necessary). The example uses the following variables:
Scripts are located in D:\Scripts
Backups are dumped to D:\Backups
Create Subfolders under Backups - Config, DBIMPEXP, LIS, RGS
Lync 2010 Resource Kit is local and installed to D:\Program Files\Microsoft Lync Server 2010\ResKit
"C:\Program Files\Common Files\Microsoft Lync Server 2010\Support\DBImpExp.exe" /hrxmlfile:D:\Backups\DBIMPEXP\Backup.xml /sqlserver:YOUR_SQL_SERVER_FQDN_and_INSTANCE
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -command "cd $env:UserProfile; Import-Module 'C:\Program Files\Common Files\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1'; Import-Module 'D:\Program Files\Microsoft Lync Server 2010\ResKit\RgsImportExport.ps1'; D:\Scripts\lync_backup.ps1
Export-CsConfiguration -FileName D:\Backups\Config\config.xml;
Export-CsLisConfiguration -FileName D:\Backups\LIS\lis.xml;
Export-CsRgsConfiguration ApplicationServer:YOUR_POOL_SERVER_FQDN –FileName D:\Backups\RGS\rgs.zip;
To automate the tasks create a Scheduled Task on a Lync Front-End server and schedule the task with a service account that has full NTFS permissions to the D:\Backups folder (and subfolders/files), is a member of the RTCUniversalServerAdmins group, and has Log on as a batch job rights.
Create Scheduled Task
Launch from the Administrative Tools Task Scheduler
Click the Task Scheduler Library and right-click to Create a Basic TaskName the task – Lync Backups (as an example)
Create a schedule – this needs to mimic your local backup jobs so that the daily/weekly/etc. backups gather the backups you create (in the example we used Daily at midnight
Finish the task creation and then double-click the task to edit it further
Modify the Security
Set to Run whether user is logged in or not
Save the task entering the password when prompted and you are done
Testing of the task may be completed by right-clicking on the task and selecting Run. Don’t forget to backup the D:\Backups directory as well as the SQL databases and Lync share to gather all Lync info.