1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- Option Explicit
- on error resume next
- if WScript.Arguments.Length = 0 then
- WScript.Echo "Ñêðèïò ñîçäàíèÿ ðåçåâíîé êîïèè äàííûõ ñåðâåðà áåçîïàñíîñòè Secret Net Studio" & VbCrLf & _
- "Èñïîëüçîâàíèå: CScript.exe " & WScript.ScriptName & " <ïóòü ê ïàïêå ñ ðåçåðâíîé êîïèåé>"
- WScript.Quit(-1)
- end if
- Dim ISODate
- ISODate = FormatNumber(Year(Now),0,,,vbFalse) & "-" &_
- Right("0" & FormatNumber(Month(Now),0), 2) & "-" &_
- Right("0" & FormatNumber(Day(Now),0), 2) & "-" &_
- Right("0" & FormatNumber(Hour(Now),0), 2) & "-" &_
- Right("0" & FormatNumber(Minute(Now),0), 2) & "-" &_
- Right("0" & FormatNumber(Second(Now),0), 2)
- dim objFSO, objShell
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objShell = WScript.CreateObject("WScript.Shell")
- if not objFSO.FolderExists (WScript.Arguments(0)) then
- WScript.Echo "Îøèáêà: ïàïêà " & WScript.Arguments(0) & " íå ñóùåñòâóåò"
- Wscript.Quit(-1)
- end if
- dim BackupDir
- BackupDir = objFSO.BuildPath (WScript.Arguments(0), ISODate)
- const ServerDirKey = "HKLM\SOFTWARE\Security Code\Secret Net Studio\Server\Security Server\LacusServerInstallDir"
- dim ServerDir
- ServerDir = objShell.RegRead (ServerDirKey)
- if (err.number <> 0) or (Len(ServerDir) = 0) then
- WScript.Echo "Îøèáêà: îøèáêà ÷òåíèÿ êëþ÷à ðååñòðà " & ServerDirKey
- Wscript.Quit(-1)
- end if
- dim ConfigFile
- ConfigFile = objFSO.BuildPath (ServerDir, "ServerConfig.xml")
- objFSO.CreateFolder (BackupDir)
- if err.number then
- WScript.Echo "Îøèáêà ñîçäàíèÿ ïàïêè " & BackupDir & ", errcode = " & err.number
- Wscript.Quit(err.number)
- end if
- objFSO.CopyFile ConfigFile, BackupDir & "\"
- if err.number then
- WScript.Echo "Îøèáêà êîïèðîâàíèÿ ôàéëà " & ConfigFile & ", errcode = " & err.number
- Wscript.Quit(err.number)
- end if
- dim Command, ErrCode
- Command = "%systemroot%\system32\dsdbutil.exe " & _
- """activate instance SecretNet"" ifm ""create full " & _
- objFSO.BuildPath (BackupDir, "SecretNet") & """ quit quit"
- ErrCode = objShell.Run (Command, 1, true)
- if ErrCode then
- WScript.Echo "Îøèáêà âûïîëíåíèÿ " & Command & ", errcode = " & ErrCode
- Wscript.Quit(ErrCode)
- end if
- Command = "%systemroot%\system32\dsdbutil.exe " & _
- """activate instance SecretNet-GC"" ifm ""create full " & _
- objFSO.BuildPath (BackupDir, "SecretNet-GC") & """ quit quit"
- ErrCode = objShell.Run (Command, 1, true)
- if ErrCode then
- WScript.Echo "Îøèáêà âûïîëíåíèÿ " & Command & ", errcode = " & ErrCode
- Wscript.Quit(ErrCode)
- end if
- WScript.Echo "Ðåçåðâíàÿ êîïèÿ äàííûõ ñåðâåðà áåçîïàñíîñòè óñïåøíà ñîçäàíà â ïàïêå " & BackupDir
|