Forum

Automating Backups ...
 
Bildirimler
Hepsini Temizle

Automating Backups of Lync 2010 Configuration

4 Yazılar
3 Üyeler
0 Reactions
518 Görüntüleme
(@evrenbanger)
Gönderiler: 2439
Üye
Konu başlatıcı
 

Bu Script ile Lync 2010 conf yedegini alabilirsiniz.
Download icin : https://sites.google.com/a/onesimplescript.com/files/home/Backup-LyncConfig.ps1?attredirects=0&d=1

#

# Backup-LyncConfig.ps1
# Written by Ben Lye - www.onesimplescript.com
#
# This script will back up the configuration of all Lync Server 2010 servers in the topology
# It is designed to be run centrally and store all the backups in a central location
#
# The Lync Resource Kit in order to back up response groups:
#
# The Lync support tools are required to back up Lync user data, and PowerShell Remoting must be
# enabled on Standard Edition servers in order to run the backup remotely.
#
 
# Import the Lync PowerShell Module
Import-Module Lync
 
# Import the resource kit script for backing up response groups
Import-Module 'C:\Program Files\Microsoft Lync Server 2010\ResKit\RgsImportExport.ps1'
 
# Define a path to store all the backup files
$BackupPath = "C:\LyncBackups\Backups\"
 
# Get the date string to use in the file names
# Use ddd-HH00 will result in strings like Wed-1000, meaning files will be overwritten weekly
# and also hourly if the script is run more than once an hour
# Other strings could be used so that files were overwritten daily, or not at all
$Datestamp = Get-Date -Format ddd-HH00
 
# Export the Central Management Store data
Write-Host
Write-Host "Exporting Central Management Store"
 
# Set the full local path of the backup file
$CmsBackupFile = $BackupPath + $Datestamp + "_CsCmsConfig.zip"
 
# Check if backup file already exists, remove it if it does
If (Test-Path $CmsBackupFile ) { Remove-Item $CmsBackupFile }
 
# Export the CMS configuration
Export-CsConfiguration –FileName $CmsBackupFile
 
# Export the LIS Data
Write-Host
Write-Host "Exporting Location Information Store"
 
# Set the full local path of the backup file
$LisBackupFile = $BackupPath + $Datestamp + "_CsLisConfig.zip"
 
# Check if backup file already exists, remove it if it does
If (Test-Path $LisBackupFile) { Remove-Item $LisBackupFile }
 
# Export the LIS configuration
Export-CsLisConfiguration –FileName $LisBackupFile
 
# Back up the response groups
Write-Host
Write-Host "Exporting Response Group Configuration"
 
# Get the Application Server services - App Services are where response groups run
$AppServices = Get-CsService -ApplicationServer
 
# Loop through each App Service
ForEach ($Service in $AppServices) {
 Write-Host $Service.PoolFqdn
 
 # Set the full local path of the backup file, including the FQDN of the app server
 $RgsBackupFile = $BackupPath + $Datestamp + "_" + $($Service.PoolFqdn) + "_RgsConfig.zip"
 
 # Check if backup file already exists, remove it if it does
 If (Test-Path $RgsBackupFile) { Remove-Item $RgsBackupFile }
 
 # Export the Response Group configuration
 Export-CsRgsConfiguration ApplicationServer:$($Service.PoolFqdn) –FileName $RgsBackupFile
}
 
# Back up the user data
Write-Host
Write-Host "Exporting user data"
# Get all the UserServers - these are the servers containing the user-specific data
$UserServices = Get-CsService -UserServer
 
# Loop through the UserServers
ForEach ($Service in $UserServices) {
 # Output the name of the pool we are backing up
 Write-Host $Service.PoolFqdn
 
 # Determine the database server and instance name for the pool
 $DBServer = $Service.UserDatabase.Split(":")[1]
  
 # Get the user database service for the pool
 $DBService = Get-CsService -UserDatabase -PoolFqdn $DBServer
 
 # If a SQL instance is used append it to the database path
 If ($DBService.SqlInstanceName) {
  $DBPath = $DBServer + "\" + $DBService.SqlInstanceName
 } Else {
  $DBPath = $DBServer
 }
  
 # Check if this is an Enterprise or Standard Edition pool
 # On Standard Edition the User Database service is co-located on the pool server and cannot be accessed remotely
 # On Enterprise Edition the User Database service is not co-located and can be accessed remotely
 
 # Get the details of the pool
 $Pool = Get-CSPool $Service.PoolFqdn
  
 If ($Pool.Services -like "*UserDatabase*") {
  # This is a Standard Edition pool, run the command on the remote server and copy the files back
  # Invoke the command on the remote server using PowerShell remoting
  Invoke-Command -ComputerName $Service.PoolFqdn -ArgumentList $DBPath -ScriptBlock {
   param($DBPath)
   $DBImpExp = "C:\Program Files\Common Files\Microsoft Lync Server 2010\Support\DBImpExp.exe";
   & $DBImpExp /hrxmlfile:"C:\Windows\Temp\CsUserBackupFile.xml" /sqlserver:$DBPath
  }
   
  # Define remote and local file names so that he file can be copied locally
  $RemoteFile = "\\" + $Service.PoolFqdn + "\" + "C$\Windows\Temp\CsUserBackupFile.xml"
  $LocalFile = $BackupPath + $DateStamp +"_" + $($Service.PoolFqdn)+ "_UserData.xml"
   
  # Copy the file locally
  Copy-Item $RemoteFile $LocalFile
   
 } Else {
  # This is an enterprise pool, run the command locally
  # Set the name of the backup file based on the pool FQDN and current date/time
  $LocalFile = $BackupPath + $DateStamp +"_" + $($Service.PoolFqdn)+ "_UserData.xml"
   
  # Set the  path to the DBImpExp execuatable on the remote machine
  $DBImpExp = "C:\Program Files\Common Files\Microsoft Lync Server 2010\Support\DBImpExp.exe";
   
  # Run the backup command
  & $DBImpExp /hrxmlfile:$LocalFile /sqlserver:$DBPath
 }
  
 Write-Host
}
 

 

 
Gönderildi : 30/05/2012 14:54

(@ufuktatlidil)
Gönderiler: 5718
Illustrious Member
 

Güzelmiş 🙂 Test edelim...

 
Gönderildi : 30/05/2012 14:55

Hakan Uzuner
(@hakanuzuner)
Gönderiler: 33311
Illustrious Member Yönetici
 

Merhaba, öncelikle eline sağlık güzel bir paylaşım olmuş.

Bende ek yapmak istiyorum, hem config hem db yani komple yedek almak için aşağıdaki komut setini kullanabilirsiniz

http://www.cozumpark.com/files/folders/yuklemeler/entry332653.aspx

 

Danışman - ITSTACK Bilgi Sistemleri
****************************************************************
Probleminiz Çözüldüğünde Sonucu Burada Paylaşırsanız.
Sizde Aynı Problemi Yaşayanlar İçin Yardım Etmiş Olursunuz.
Eğer sorununuz çözüldü ise lütfen "çözüldü" olarak işaretlerseniz diğer üyeler için çok büyük kolaylık sağlayacaktır.
*****************************************************************

 
Gönderildi : 06/06/2012 14:34

(@ufuktatlidil)
Gönderiler: 5718
Illustrious Member
 

Süper hocam. Emeğine sağlık.

 
Gönderildi : 06/06/2012 16:20

Paylaş: