Backend databases

Backing up databases used to be challenging or had to be done with SQL management tools. Thanks to new PowerShell commands shipped with SQL server 2012 and SQL server 2012 Express (the latter shipped with Lync 2013), backing up and restoring has become a lot easier.

The script examples given here presume that the Lync backend databases are on an isolated instance (colocation core services and monitoring databases). If not, it would be wise to read up on the list of databases to take backup of at http://technet.microsoft.com/en-us/library/gg398479.aspx. Then, adjust the following scripted examples to back up or restore only the databases needed for Lync.

Note

QOE and CDR databases can grow dramatically in large deployments and can take some time to back up and restore. Consider whether a SQL backup for these databases are vital or not.

Getting ready

The methods described for Lync Standard and Enterprise are slightly different. Standard Edition backup is done on the Lync Server, whereas a backup of an Enterprise Edition should be done on the SQL server.

Run the Get-CsService –CentralManagementDatabase command to identify the server and instance where the Lync Server has its databases.

How to do it…

The following are the five steps to back up your databases on a Standard Edition server:

  1. Launch PowerShell in the elevated administrative mode on the Front End Server for Standard Edition or on the SQL server for Enterprise Editions.
  2. Type Import-Module SQLPS –DisableNameChecking (to import the SQL commands if the SQL server is not running PowerShell v3).
  3. Type cd SQLSERVER:SQLFrontenserver.mydomain.comSQLInstanceDatabases (the server and instance information was gathered in the Getting ready section).
  4. Type the following foreach loop (no line breaks; they are here for viewing). The foreach command here will look at all the databases in the instance (except tempdb) and then back them up to individual files:
    foreach($database in (Get-ChildItem -name -force)) {'
    $dbName = $database' 
    $bakFile = "c:ackup" + $dbName + "_full_.bak"' 
    If($dbName -ne "tempdb"){'
    Backup-SqlDatabase -Database $dbName -BackupFile $bakFile -Initialize}}
    
  5. Store the files in a secure location.

How to restore…

Restoring is not much different from backing up, and here are the four easy steps to restore your databases:

  1. Launch PowerShell in the elevated mode on the Front-End Server for Standard Edition or on the SQL server for Enterprise Editions.
  2. Type Import-Module SQLPS –DisableNameChecking (to import the SQL commands).
  3. Type cd SQLSERVER:SQLFrontend?server.mydomain.comSQLInstanceDatabases (the server and instance information was gathered in the Getting ready section).
  4. For each database to restore, type the following command (replace rtc with the correct database):
    Restore-SqlDatabase -ServerInstance SQLInstance -Database rtc '
    -BackupFile "c:BackupRtc_full_.bak" –ReplaceDatabase 
    

    Note

    You will need to restore each database individually, and if the -Replace switch is used, it would overwrite everything in the target location.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.195.225