Lync Backup Instructions

This script is to be run on a Lync Front End server that has the SQL client and tools installed

On your Lync Front End server, create a folder called “backup” on the root of C:\. Copy this into a Notepad file and name it “backup.ps1”. Copy the following three other files into the same backup folder.

***Change the SQLserver\InstanceName, LyncShare path/name as well as domain\administrator and password.***

This script backs up the CSConfig, LISConfig, Contact Lists and Conference Directories, all SQL databases and the certificates in the local Computer store

cd $env:UserProfile
Import-Module 'C:\Program Files\Common Files\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1'
$filename = "c:\backup\{0:yyyy.MM.dd-HH.mm}-CSconfig.zip" -f (Get-Date)
$filename1 = "c:\backup\{0:yyyy.MM.dd-HH.mm}-LISconfig.zip" -f (Get-Date)
export-csconfiguration -Filename $filename -Force:$True
export-cslisconfiguration -Filename $filename1
c:\backup\dbimpexp.bat

osql -E -S sql2008\RTC -i c:\backup\backup.sql

Net Use b: \\sql2008\LyncShare
Xcopy B:\ c:\Backup\LyncShare /E /I /Y
Net Use B: /delete

Net Use S: \\sql2008\c$\Backup /User:Domain\Administrator p@ssw0rd1
Xcopy S:\ c:\Backup\SQLdbBackup /E /I /Y
Net Use S: /delete

dir cert:\localmachine\my |
Where-Object { $_.hasPrivateKey } |
Foreach-Object { [system.IO.file]::WriteAllBytes(
"c:\backup\$($_.thumbprint).pfx",
($_.Export('PFX', 'secret')) ) }

cd\

 

 

 

DBImpExp - Backup Contact Lists and Conference Directories  - Copy the following text and create a Batch file, name it “DBImpExp.bat” and place it in the “C:\Backup” folder

**Change the name of your SQLserver\Instance**

@ECHO OFF
REM For Standard Edition
"C:\Program Files\Common Files\Microsoft Lync Server 2010\Support\dbimpexp.exe" /hrxmlfile:"c:\backup\DBImpExp.xml"
@ECHO OFF
REM For Enterprise Edition
REM "C:\Program Files\Common Files\Microsoft Lync Server 2010\Support\dbimpexp.exe" /hrxmlfile:"c:\<fullFilePath>.xml" /sqlserver:<sql server host name>

Backup All SQL databases

Copy this into a Notepad file and name it “backup.sql” . Save this file into the C:\Backup folder on your Lync server. Create a folder called "Backup" on your C: on your SQL server and save this file there as well

DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name

SET @path = 'C:\Backup\'

SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)

DECLARE db_cursor CURSOR FOR
SELECT name
FROM master.dbo.sysdatabases
WHERE name NOT IN ('master','model','msdb','tempdb')

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name

WHILE @@FETCH_STATUS = 0
BEGIN
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName

           FETCH NEXT FROM db_cursor INTO @name
END

CLOSE db_cursor
DEALLOCATE db_cursor

Backup Certificates with Private Keys - This is already built into the backup.ps1 script but it can be used by its self on other machines that are not FE servers to backup the certificates and private keys.

dir cert:\localmachine\my |

Where-Object { $_.hasPrivateKey } |

Foreach-Object { [system.IO.file]::WriteAllBytes(

"c:\backup\$($_.thumbprint).pfx",

($_.Export('PFX', 'secret')) ) }

Backup Voice Configurations (from Cscp)

 

Create a Scheduled Task in Windows

Create a new task for: powershell -command C:\Backup\backup.ps1

Now that you have all your backup files in one location, you can use Windows backup or any other backup software to backup your “c:\Backup” folder

 

 

Additionally you need to make sure that other components that Lync relies upon should be backed up:

· AD (both the RTC Service container and all users for policy and pool assignments)

· Load balancer configurations

· Firewall configurations

· DNS configurations

· DHCP configurations

· PSTN gateway configurations

The frequency of the backups should be determined by each individual company’s policies.

It is also important to make sure that you have a DR plan that includes both restoring data and plans for restoring services (user services, conferencing, etc.) during the outage.

 

 

Written By: Traci Herr, tracisy@microsoft.com, Microsoft Consulting Services, 3/8/11

Lync Backup Instructions.docx