OCS 2007 Backup Script

One of the more useful items from the OCS 2007 Resource Kit book was the extras disc that contained a few Excel worksheets on setting up backups for different types of servers. Using those worksheets I created a script that automates some of the backup process for a standard edition server. I tried to make the script fairly configurable as far as file locations and naming conventions, but feel free to change it to suit your needs. What happens is this:

  • A SQL backup job script is created with options for a full backup that overwrites the previous one.
  • A scheduled task is created that backs up the global and pool-level settings for OCS.
  • A scheduled task is created that backs up the machine-level settings for OCS.
  • A scheduled task is created that runs the SQL backup job script.

All of the files from these tasks are dumped into a single folder of your choosing on a nightly basis. At that point you can do what you like with the contents. You could schedule your backup program to simply pick up this folder on a regular schedule or you could create another scheduled task that copies the folder to a file share on another machine. Just make sure you’re saving that folder collection somewhere else and you should be fine.

There is one manual change you must make before the SQL backup job can run successfully. You need to enable TCP/IP connections to the SQL Express instance and change the port back to the default. To do that, perform these steps:

  1. Install SQL Server Management Studio Express.
  2. Open Start | Programs | MS SQL Server 2005 | Configuration Tools | SQL Server Configuration Manager.
  3. Expand SQL Server 2005 Network Configuration | Protocols for RTC.
  4. Right-clickTCP/IP and choose Enable.
    sql1
  5. Right-click TCP/IP | Properties and change the TCP Dynamic Ports value to 1433.
    sql2 
  6. Restart the SQl Server (RTC) service and you should be all set.

To use the script just rename the link to a .vbs and execute it. A few things to keep in mind:

  • Run the script as a user who is both a member of RTCUniversalAdmins and in the local administrators group on the machine.
  • You’ll be prompted for your password 3 times, once for each scheduled task.
  • Make sure you manually run the tasks a few times make sure they work properly.
  • Read the comments in the script - I tried to be detailed and make it easy to follow if you need to change something.

OCS Standard Edition Backup Script 

  1. '———————————————-   
  2. 'Edit these values   
  3. '———————————————-   
  4.  
  5. 'Backup folder - this is directory the files are saved to. Do   
  6. 'NOT use a trailing backslash. You MUST create the folder   
  7. 'before running the script.   
  8. strBackupFolder = "C:\OCS 2007 Configuration"   
  9.  
  10. 'Global & Pool Level File Name - this is the file name of the   
  11. 'XML used for storing global and pool level settings   
  12. strGlobalPoolLevelFileName = "ocs-2007-global-pool-settings.xml"   
  13.  
  14. 'Global & Pool Level File Name - this is the file name of the   
  15. 'XML used for storing machine level settings. By default it   
  16. 'includes the machine name.   
  17. strMachineLevelFileName = "ocs-2007-machine-settings.xml"   
  18.  
  19. 'Global & Pool Level Task Name   
  20. strGlobalPoolTaskName = "OCS 2007 - Global and Pool Level Settings Backup"   
  21.  
  22. 'Global & Pool Level Task Start Time   
  23. strGlobalPoolTaskStart = "04:00"   
  24.  
  25. 'Machine Level Task Name   
  26. strMachineTaskName = "OCS 2007 - Machine Level Settings Backup"   
  27.  
  28. 'Machine Level Task Start Time   
  29. strMachineTaskStart = "04:05"   
  30.  
  31. 'SQL Backup Task Name   
  32. strSQLBackupTaskName = "OCS 2007 - Database Backup"   
  33.  
  34. 'SQL Backup Start Time   
  35. strSQLBackupTaskStart = "04:10"   
  36.  
  37. 'SQL Backup Script Name   
  38. strSQLBackupScriptName = "ocs-backup-job.sql"   
  39.  
  40. 'SQL Backup File Name   
  41. strSQLBackupFileName = "rtc-full.bak"   
  42.  
  43. '———————————————-   
  44. 'You can probably leave this section alone   
  45. '———————————————-   
  46.  
  47. set objFSO = CreateObject ("Scripting.FileSystemObject")   
  48. Set objFile = objFSO.CreateTextFile("" & strBackupFolder & "\" & strSQLBackupScriptName & "",True)   
  49. objFile.WriteLine("BACKUP DATABASE [rtc] TO  DISK = N’" & strBackupFolder & "\" & strSQLBackupFileName & "’ WITH NOFORMAT, INIT,  NAME = N’rtc-Full Database Backup’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10")   
  50. objFile.WriteLine("Go")   
  51. objFile.Close   
  52.  
  53. 'Create an array of OCS Pools   
  54. strComputer = "."   
  55. Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")   
  56. Set colOCSPools = objWMIService.ExecQuery("Select * from MSFT_SIPPoolSetting")   
  57.  
  58. 'Get name of OCS pool   
  59. For Each objOCSPool in colOCSPools   
  60.   strOCSPool = objOCSPool.pooldisplayname   
  61. Next   
  62.  
  63. 'Create task for global and pool settings backup   
  64. Set objShell = WScript.CreateObject("WScript.Shell")   
  65. taskParameters = "/create /sc daily /st " & strGlobalPoolTaskStart & " /tr ""\""%programfiles%\Common Files\Microsoft Office Communications Server 2007\LCSCmd.exe\""/config /action:export /level:global,pool /configfile:\""" & strBackupFolder & "\" & strGlobalPoolLevelFileName & "\"" /poolname:" & strOCSPool & """ /TN """ & strGlobalPoolTaskName &""""   
  66. objShell.Run "schtasks.exe " & taskParameters   
  67.  
  68. 'Create task for machine settings backup   
  69. taskParameters = "/create /sc daily /st " & strMachineTaskStart & " /tr ""\""%programfiles%\Common Files\Microsoft Office Communications Server 2007\LCSCmd.exe\""/config /action:export /level:machine /configfile:\""" & strBackupFolder & "\" & strMachineLevelFileName & "\"" /poolname:" & strOCSPool & """ /TN """ & strMachineTaskName &""""   
  70. objShell.Run "schtasks.exe " & taskParameters   
  71.  
  72. 'Create task for SQL backup   
  73. taskParameters = "/create /sc daily /st " & strSQLBackupTaskStart & " /tr ""sqlcmd.exe -e -s .\RTC -i \""" & strBackupFolder & "\" & strSQLBackupScriptName & "\"""" /TN """ & strSQLBackupTaskName &""""   
  74. objShell.Run "schtasks.exe " & taskParameters 
此文章由 flyinweb 于 2009-10-19 11:31:17 编辑

本日志由 flyinweb 于 2009-10-19 11:28:03 发表,目前已经被浏览 3948 次,评论 0 次;

作者添加了以下标签: OCS Backup ScriptOCS备份脚本

引用通告:http://www.517sou.net/Article/293/Trackback.ashx

评论订阅:http://www.517sou.net/Article/293/Feeds.ashx

评论列表

    暂时没有评论
(必填)
(必填,不会被公开)