Weekend Scripter: Basic Lync Server 2013 Backup and Restore—Part 1

Doctor Scripto

Summary: Learn how to make a rudimentary backup for a simple Lync Server environment. Honorary Scripting Guy, Sean Kearney, is here. Today we’re going to play a game of “Let’s Pretend.” Let’s pretend you got hired in a new company or are taking over from someone who had to deploy a simple Lync infrastructure. This will be a bit more complex than last week when we talked about simple management techniques for Lync Server 2013. Be sure to read this series of Hey, Scripting Guy! Blog posts: Managing Lync Server 2013 with Windows PowerShell. This time, our configuration will be:

  • Lync Server 2013 Standard as a front edge
  • Lync Server 2013 Standard in an edge configuration
  • A server running IIS for Application Request Routing (ARR)
  • Servers are virtualized

So the question is, “How do you want to back up this puppy?” The magic answer is (of course as always in the IT community), “It depends.”

  • How much space do you have available for backup?
  • What’s your available software?
  • What is the acceptable downtime?

And the list can go on and on—like any server. Before we go any further, I’m going to point you to Backing Up and Restoring Lync Server 2013. This topic discusses all the ins and outs of backing up your Lync environment. From a simple standpoint, you could back up the virtual machine as a whole—the entire file structure in one complete swoop. All three machines! Is that a good approach? I can say from personal experience that it does work and it requires very little effort to restore. It does, however, require time. And the bigger those servers are, the more time it will take to restore them. It also takes more space (you’re going to have to put all that data somewhere). So let’s go with a smarter approach. Let’s find out what the server actually needs to have restored. (There’s a concept.) Let’s assume that last weekend we took care of most of the prerequisites for creating a Lync server. The Lync infrastructure was hauled off by Zaphod Beeblebrox in the Heart of Gold. It seems improbable, which is most likely why it happened. Now we have a disaster recovery scenario. We could plug together most of the prerequisites we created last week as part of a disaster recovery Windows PowerShell script. But think about it. If you were to leverage SCCM, MDT, or any approach for spinning up a new machine with ease, and simply spin up a fresh Lync server afterwards, what’s missing? All together now class: THE CONFIGURATION. So the first part (as we read about in Backing Up and Restoring Lync Server 2013) lives in the wonderful world of Windows PowerShell. (What do you mean you didn’t read the documentation? No soup for you!) So we’ll need our Lync topology—the very file that defines our Lync infrastructure. We can retrieve this by using the Export-CSConfiguration cmdlet. (We’ll presume that in all of the following examples, you’re storing the files in a folder called C:Backup, and we’re running it on the Lync server.)

Export-CSConfiguration –filename C:BackupTopology.zip This will create a simple ZIP file that contains your Lync Server 2013 topology. Then we’ll grab information from the Central Management store. One cmdlet again. Export-CSLisConfiguration will save the day:

Export-CSLisConfiguration –filename C:BackupCentralMgmtStore.zip This creates a simple ZIP file that contains the information from your Central Management store. In our case, we are running a single front-end server, so we need to run the following cmdlet only once. This backs up all the user data from the SQL Server database on that front-end server:

Export-CsUserData -PoolFQDN eot-lync.contoso.local -FileName C:BackupEOT-Lync.zip In addition, we should make sure that our SSL certificate file is backed up. Yes! We can do that with Windows PowerShell:

GET-ChildItem CERT:localmachinemy | where { $_.HasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes(“C:Backup$($_.thumbprint).pfx”, ($_.Export(‘PFX’, ‘secret’)) ) } So for our Lync server, we could have a single Windows PowerShell script to get the bulk of the information for the backup like this:

Export-CSConfiguration –filename C:BackupTopology.zip

Export-CSLisConfiguration –filename C:BackupCentralMgmtStore.zip

Export-CsUserData -PoolFQDN eot-lync.contoso.local -FileName C:BackupEOT-Lync.zip

GET-ChildItem CERT:localmachinemy | where { $_.HasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes(“C:Backup$($_.thumbprint).pfx”, ($_.Export(‘PFX’, ‘secret’)) ) } Then the only thing that we need do is back up the file stores (which are in a single shared folder on your Lync server). Do you see something nice going on here? It means that stock out-of-the-box, we don’t need an expensive agent to back up Lync Server. We can simply leverage a standard file server agent (versus using a SQL Server backup). It doesn’t negate that option. The more ways you have to back up, the merrier. But it does mean that with a little Windows PowerShell, you can get all the data you need in one shot! Pop in tomorrow and we’ll look and what is need to back up the IIS server that is running the ARR, then we can all sit back and enjoy a round of Pan Galactic Gargle Blasters! I invite you to follow the Scripting Guys on Twitter and Facebook. If you have any questions, send an email to the Scripting Guys at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then just remember, the Power of Shell is in You. Sean Kearney, Windows PowerShell MVP and Honorary Scripting Guy 

0 comments

Discussion is closed.

Feedback usabilla icon