Backup Skype for Business On-Premise

This is a simple script to back up your Lync 2013 or Skype for Business (SfB) Standard or Enterprise Edition Server to a single zip.file. It does not only make a copy of your topology, but will make a backup of your IIS files, your SQL server databases and much more.This is rea

4.9 Star
8,284 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • StoreBackupTo
    1 Posts | Last post January 15, 2019
    • Suggestion:  any way of making the StoreBackupTo process create the ZIP file locally and THEN move the ZIP to the location StoreBackupTo specified?  
      Our backup jumped from 250mb to 1.8Gb (my fault, loaded up a 280Mb PPT) anyway, the backup took about 1.5 hours to complete instead of 20 min, and watching the Resource Monitor, I saw it was transferring each individual file in the UCBackup subfolder over the network, instead of just one ZIP file...
  • Suggested change to filename for exported certificate
    1 Posts | Last post June 18, 2018
    • Hi Lasse, thanks for the great script.
      Once issue we have had in our system is exporting the scripts - the script generates an error exporting the cert as the certificate friendly name contains a wildcard * and thus the exported file name has a wildcard, which is an invalid character for a filename.
      In order to fix this I added a function call to replace "*" with "(STAR)" on line 679 of your script:
      ... + $($_.FriendlyName.Replace("*", "(STAR)")) + ...
      This means that our wildcard cert is exported into the backup with no issue, and other certificates are not affected.
      I thought I'd share this in case any others have this issue, and if you want to add it to the next version of your script.
      Kind regards
  • how to use sendemailoncomplete?
    2 Posts | Last post April 12, 2018
    • Hi,
      Could you please provide example of using the sendemail function. 
      I am using the latest version of this script as of this writing and with Skype for business server 2015 standard edition pool, windows server 2016 and i get an error.
      when i call the script i am trying to use...
      PS C:\scripts> .\Backup-SfB.ps1 -SendEmailOnComplete -EmailFrom -SMTPServer -EmailTo -Backupto G:\SkypeServerBackup
      C:\scripts\Backup-SfB.ps1 : Parameter set cannot be resolved using the specified named parameters.
      At line:1 char:1
      + .\Backup-SfB.ps1 -SendEmailOnComplete -EmailFrom xxx@xxx ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (:) [Backup-SfB.ps1], ParameterBindingException
          + FullyQualifiedErrorId : AmbiguousParameterSet,Backup-SfB.ps1
    • The parameters I wanted to use are ambiguous whereas they should resolve to the parameterset BasicSendM
      A friend has helped me get around this issue by changing the default parameter set from "Basic" to "BasicSendM".
  • Blank on Line 929
    2 Posts | Last post February 15, 2018
    • the mail couldn't be send. there is a blank on function call "send_email".
    • Thanks,
      Should be fixed now
  • Support for SQL Mirror back end
    2 Posts | Last post February 15, 2018
    • Hi Lasse,
      I've noticed that your script only backs up the SQL backend databases from a mirror when they are principle on the primary server. The problem is in the way that the script determines the SQL server to backup from. For instance, for the CMS it uses (Get-CsConfigurationStoreLocation).BackEndServer which always returns the primary mirror server. If the databases are principle on the secondary, then the MirrorBackEndServer property should be used.
      Before I start looking in to a way to work round this, I wondered if you are aware of this or, better still, have plans to fix it?
      I guess there are three options:
      - Fail all of the databases to the primary before running your script (I prefer to keep an eye on this process).
      - Check where the databases are and include some logic in the script to use the appropriate property accordingly.
      - Attempt to backup from both primary and secondary so it doesn't matter where the databases are currently principle.
      Once again, thanks for the awesome script.
    • Hi,
      Sorry for the late reply here, I was not aware of this issue.
      Thing is, SQL is not my strongest technology.
  • SendEmailOnCompletion
    4 Posts | Last post February 15, 2018
    • Hi Lasse,
      Thanks for developing this awesome script.
      I am not sure how to use the SendEmailOnCompletion parameter. When I use the switch I receive an error: Parameter set cannot be resolved using the specified named parameters.
      Can you please explain how this should be used?
      Best regards,
    • Seems there is missing a few lines of code in the script regarding the SendEmailOnCompletion
    • Hi Steffen,
      That's what I thought as well. Hope that Lasse will (re) enable this functionality in a future release.
    • Sorry, for some reason I have not gotten any of these notifications...
      Adding a v4.2a in a few seconds, fixing the line 928 (where there i s typo in the call function to send mail)
      PS: these are the valid params:
      [-SendEmailOnComplete] -EmailFrom <String> -EmailTo <String> -SMTPServer <String> [<CommonParameters>] 
  • Updated Backup-Certs
    1 Posts | Last post February 08, 2018
    • I had an issue where the slashes in the Friendly Name of the cert caused the Backup-certs function to fail. My fix was to add another function, Remove-InvalidFileNameChars. Updates below:
      function Backup-certs {
          $selectCert = Get-CsCertificate
          $filepath77 = $filepath7 + "\" + $($LocalServer.Name)
          New-Item $filepath77 -type directory -force  | out-null
          cd $filepath77
          foreach ($certh in $selectCert){
              dir cert:\localmachine\my |Where-Object { $_.HasPrivateKey -and !$_.PrivateKey.CspKeyContainerInfo.Exportable -and $_.thumbprint -eq $certh.thumbprint}|
              ForEach-Object {Write-Output ("Certificate " + $_.thumbprint + " not exportable!!")}
              dir cert:\localmachine\my | 
              Where-Object { $_.HasPrivateKey -and $_.PrivateKey.CspKeyContainerInfo.Exportable -and $_.thumbprint -eq $certh.thumbprint} | 
              Foreach-Object {
              $certName = $filepath77 +"\" + $certh.use + " - " + $(Remove-InvalidFileNameChars -Name $_.FriendlyName) + " - " + $($_.thumbprint) + ".pfx";
              $testPath = "*" + $($_.thumbprint) + ".pfx"
              if(!(Test-Path -Path $testPath)){
              [system.IO.file]::WriteAllBytes($certName,($_.Export('PFX', $CertPass)))
      Function Remove-InvalidFileNameChars {
      return [RegEx]::Replace($Name, "[{0}]" -f ([RegEx]::Escape([String][System.IO.Path]::GetInvalidFileNameChars())), '')
  • Clean up of older backups in custom storebackupto path
    3 Posts | Last post November 30, 2017
    • Hi Lasse,
      Firstly, many thanks for you efforts on this script. It's excellent!
      I'm running version 4.2 and scheduling the script to run using the new -basic -user scenario parameters. I have also specified a custom -backupTo and -StoreBackupTo filepaths.
      I've noticed that the default delete older backups than 5 days does not remove the backups from the custom -storebackupto filepath/folder.
      I might be missing how to set this, or how to edit to resolve, but advice will be greatly appreciated, thanks in advance.
    • Thank you for bringing this to my attention,
      I think maybe I know where my coding went wrong, I'll make sure to investigate this in an upcoming release
    • I have modified cleanup-run function, now it delete logs from -backupTo folder and backup zip files from -storebackupto filepath
      function cleanup-run{
          if(!(Test-Path -Path $filepath)){
              Write-Output "$filepath not found, nothing to delete"
              $Days = $KeepDaysLog 
              $CurrentDate = Get-Date
              $DatetoDelete = $CurrentDate.AddDays($Days)
              $StoreBackupPath = $StoreBackupTo + "\"
              Get-ChildItem $filepath -recurse | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item -force -Recurse | Out-Null
              Get-ChildItem $StoreBackupPath -recurse | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item -force -Recurse | Out-Null
  • Error export configs
    1 Posts | Last post August 02, 2017
    • Hi Lasse,
      I got loads of errors like Export-Clixml : Could not find a part of the path
      I did some research, and the cleanup-run deleted the just created directories. The DatetoDelete was in the future, not in the past. I changed it in $DatetoDelete = $CurrentDate.AddDays(-$Days) (added the minus) and now it's working fine.
  • Exclusion of DfsrPrivate folder from file share backup
    5 Posts | Last post April 09, 2017
    • Hi Lasse,
      Thanks a million for the superb backup script.
      I came up against a problem where the file share backup was hanging while trying to backup a share based on DFS. The xcopy process hung while trying to backup the hidden system folder "DfsrPrivate". I excluded it from the copy by amending the script from line 234 and the script then proceeded as normal. I wonder if you've come across this before?
      Also, I decided to exclude the "WinFabDumpFiles" and "WinFabTraceFiles" folders as the "WinFabTraceFiles" in particular is quite large with over 10000 files and I don't think it would be a good idea to restore these files during a recovery. What do you think?
      Many thanks,
    • Hi Toby!
      To be honest, the WinFabDumpFiles folders were quite small when I wrote the previous update to this script. I have seen the same as you, and I am quite positive these files are not required for a restore and can be skipped (just added to the to-do-list).
      I don't have a deployment with DFS shares available at the moment, but I take your word for it. I will look into it once I get my hands on a DFS deployment.
    • Hi,
      I'm seeing a similar issue with the backup stalling when copying from our DFS fileshare.
      How did you exclude the the folder tobewah?
      "DfsrPrivate" | Out-File $excludeFile1 -Append ?
    • Hi Skakke,
      Depending on which option you are using, it could be any of the files used.
      I am working on an update, excluding the path by default.
      Here is the code I have prepared for the three files in use:
          $excludeFile1 = $env:temp + "\exclude.txt"
          #List of excluded directories from xopy
          "ABfiles" | Out-File $excludeFile1
          "DeviceUpdateStore" | Out-File $excludeFile1 -Append
          "Meeting.Active" | Out-File $excludeFile1 -Append
          "DfsrPrivate" | Out-File $excludeFile1 -Append
          $excludeFile2 = $env:temp + "\excludeabs.txt"
          #List of excluded directories from xopy
          "ABfiles" | Out-File $excludeFile2
          "Meeting.Active" | Out-File $excludeFile2 -Append
          "DfsrPrivate" | Out-File $excludeFile2 -Append
          $excludeFile3 = $env:temp + "\excludedev.txt"
          #List of excluded directories from xopy
          "DeviceUpdateStore" | Out-File $excludeFile3
          "Meeting.Active" | Out-File $excludeFile3 -Append
          "DfsrPrivate" | Out-File $excludeFile3 -Append
      I am also looking on excluding WinFab files in an upcoming release.
    • I am working on an update to take care of the issues mentioned by tobewah.
      But yes Skakke, you are right. Just make sure you also add the statement for excludefile2 and 3 if you use those options.
1 - 10 of 19 Items