BackupServerData2008_2012.vbs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. Option Explicit
  2. on error resume next
  3. if WScript.Arguments.Length = 0 then
  4. WScript.Echo "Ñêðèïò ñîçäàíèÿ ðåçåâíîé êîïèè äàííûõ ñåðâåðà áåçîïàñíîñòè Secret Net Studio" & VbCrLf & _
  5. "Èñïîëüçîâàíèå: CScript.exe " & WScript.ScriptName & " <ïóòü ê ïàïêå ñ ðåçåðâíîé êîïèåé>"
  6. WScript.Quit(-1)
  7. end if
  8. Dim ISODate
  9. ISODate = FormatNumber(Year(Now),0,,,vbFalse) & "-" &_
  10. Right("0" & FormatNumber(Month(Now),0), 2) & "-" &_
  11. Right("0" & FormatNumber(Day(Now),0), 2) & "-" &_
  12. Right("0" & FormatNumber(Hour(Now),0), 2) & "-" &_
  13. Right("0" & FormatNumber(Minute(Now),0), 2) & "-" &_
  14. Right("0" & FormatNumber(Second(Now),0), 2)
  15. dim objFSO, objShell
  16. Set objFSO = CreateObject("Scripting.FileSystemObject")
  17. Set objShell = WScript.CreateObject("WScript.Shell")
  18. if not objFSO.FolderExists (WScript.Arguments(0)) then
  19. WScript.Echo "Îøèáêà: ïàïêà " & WScript.Arguments(0) & " íå ñóùåñòâóåò"
  20. Wscript.Quit(-1)
  21. end if
  22. dim BackupDir
  23. BackupDir = objFSO.BuildPath (WScript.Arguments(0), ISODate)
  24. const ServerDirKey = "HKLM\SOFTWARE\Security Code\Secret Net Studio\Server\Security Server\LacusServerInstallDir"
  25. dim ServerDir
  26. ServerDir = objShell.RegRead (ServerDirKey)
  27. if (err.number <> 0) or (Len(ServerDir) = 0) then
  28. WScript.Echo "Îøèáêà: îøèáêà ÷òåíèÿ êëþ÷à ðååñòðà " & ServerDirKey
  29. Wscript.Quit(-1)
  30. end if
  31. dim ConfigFile
  32. ConfigFile = objFSO.BuildPath (ServerDir, "ServerConfig.xml")
  33. objFSO.CreateFolder (BackupDir)
  34. if err.number then
  35. WScript.Echo "Îøèáêà ñîçäàíèÿ ïàïêè " & BackupDir & ", errcode = " & err.number
  36. Wscript.Quit(err.number)
  37. end if
  38. objFSO.CopyFile ConfigFile, BackupDir & "\"
  39. if err.number then
  40. WScript.Echo "Îøèáêà êîïèðîâàíèÿ ôàéëà " & ConfigFile & ", errcode = " & err.number
  41. Wscript.Quit(err.number)
  42. end if
  43. dim Command, ErrCode
  44. Command = "%systemroot%\system32\dsdbutil.exe " & _
  45. """activate instance SecretNet"" ifm ""create full " & _
  46. objFSO.BuildPath (BackupDir, "SecretNet") & """ quit quit"
  47. ErrCode = objShell.Run (Command, 1, true)
  48. if ErrCode then
  49. WScript.Echo "Îøèáêà âûïîëíåíèÿ " & Command & ", errcode = " & ErrCode
  50. Wscript.Quit(ErrCode)
  51. end if
  52. Command = "%systemroot%\system32\dsdbutil.exe " & _
  53. """activate instance SecretNet-GC"" ifm ""create full " & _
  54. objFSO.BuildPath (BackupDir, "SecretNet-GC") & """ quit quit"
  55. ErrCode = objShell.Run (Command, 1, true)
  56. if ErrCode then
  57. WScript.Echo "Îøèáêà âûïîëíåíèÿ " & Command & ", errcode = " & ErrCode
  58. Wscript.Quit(ErrCode)
  59. end if
  60. WScript.Echo "Ðåçåðâíàÿ êîïèÿ äàííûõ ñåðâåðà áåçîïàñíîñòè óñïåøíà ñîçäàíà â ïàïêå " & BackupDir