JadeKnight
IS-IT--Management
I've created a backup script, maybe others might need it or parts of it. Since this has been my #1 forum, I thought I should share it with you...
SBBS.vbs :
Sample definition file :
SBBS.vbs :
Code:
'***************************************************************************************************************************
' Script Based Backup System Ver. 1.0
'***************************************************************************************************************************
'Copyright (C) 2005 Nils-Erik Auråker, nils-erik.auraaker@toetip.com
'
'This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
'as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
'
'This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
'of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
'
'You should have received a copy of the GNU General Public License along with this program; if not, write to the
'Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'
'
'Special Thanks to :
'Alexander Stensrud - Suggestions/Solutions
'Guys from VBScript Forum at [URL unfurl="true"]http://www.tek-tips.com[/URL] for always providing fast/solid answear : PHV, tsuji, mrmovie
'---------------------------------------------------------------------------------------------------------------------------
'********
'Abstract
'********
'Uses NTBackup to perform backup of any data limited to the functionality of NTBackup. Funtion
'of Windows Script Based Backup System (hereafter refered to as SBBS) beoynd NTBackup :
'- Schedule backups to run in an Enterprise without need of expensive backup software*
'- Add, remove, change jobs without changing initial job at server*
'- Store a desired number of backups locally/remote
'- Infinite backup definition files (*.bks)
'- Script definition file supporting Computervariables Ex : %ComputerName%
'- Script definition file passed as argument to SBBS.vbs
'- Choose a desired loglevel in formats Event/FileLog
'* See Enterprise Howto section
'******
'Syntax
'******
'sbbs.vbs /SDS:Filename or sbbs.vbs
'************
'Requirements
'************
'Windows Script Host 5.6 or above
'Script must be executed in system or admin context
'Script must be invoked by cscript engine
'****************
'Supported System
'****************
'Windows Server 2003 Family
'Other Windows Systems might function but is not tested. Make sure WSH 5.6 or above is used with such a system.
'************************************************
'Store a desired number of backups locally/remote
'************************************************
'You can choose how many backups you want to store locally and/or remote. SBBS.vbs will automatically rollover new versions. Deleting old version. You can
'controll how many backups you want to store in one directory by setting value of iNumberOfBackup to the desired value to keep. WARNING! This entry will
'delete all directories in root of backup, keeping n newest directories (where n is equal to value of iNumberOfBackup).
'****************************************
'Infinite backup definition files (*.bks)
'****************************************
'Backup definition files (bks) can be stored both locally or remote. Definition files are placed within one directory. All
'files within directory will be processed. If uniqe values are required, schedule several tasks. To process more than one
'file, specify a direcotry. To process one file only, specify file.
'sBks = Path to definition file (bks) or directory, default is : <scriptpath>\Store\
'****************
'Enterprise Howto
'****************
'This section is ment to give you an idea on how to fully unleash the power of SBBS.vbs in an Enterprise. This require a share with enough free disk space
'to store desired backups (Ex : SAN, NAS or a large fault tolerant volume. None of the mentioned is required, only free disk space is).
'Scenario I : Backup with same backup configuration
'Create a share named : \\server\backup$ at root of share, add SBBS.vbs, ScriptDefinition.sdf, and all of the different *.bkf wich you would like to
'process at every server (Ex : SystemState). In scriptdefinition edit the following :
'sStorage=\\server\backup$\%ComputerName%
'sBks=\\server\backup$
'iNumberOfBackup=1
'Now let's say we're going to take backup of three servers : Server1, Server2, Server3. Schedule the following tasks at every server from command line :
'schtasks /create /tn "Daily Backup" /tr "\"\\server\backup$\SBBS.vbs\" /SDF:\\server\backup$\ScriptDefinitionFile.sdf" /st 23:00 /ru /system
'(The commandline task can be added through GPO and startup script if done on large amount of servers). You have now scheduled backup to run every night at
'23:00 in context of system with common backup definitions.
'Some time after 23:00 you will then find three subfolders named : Server1, Server2, Server3 with the backup(s) you have specified in *.bks file(s) at root
'of backup$ share.
'Scenario II : Backup with different backup configuration
'Create a share named : \\server\backup$ at root of share, add SBBS.vbs, ScriptDefinition.sdf. In scriptdefinition edit the following :
'sStorage=\\server\backup$\%ComputerName%
'sBks=\\server\backup$\%ComputerName%
'iNumberOfBackup=1
'Now let's say we're going to take backup of three servers : Server1, Server2, Server3. Create a folder for every server with same name as server netbios
'name. Now add the *.bkf file(s) for every server into correspondent folder you just created.
'Schedule the following tasks at every server from command line :
'schtasks /create /tn "Daily Backup" /tr "\"\\server\backup$\SBBS.vbs\" /SDF:\\server\backup$\ScriptDefinitionFile.sdf" /st 23:00 /ru /system
'(The commandline task can be added through GPO and startup script if done on large amount of servers). You have now scheduled backup to run every night at
'23:00 in context of system with uniqe backup definitions.
'Summary :
'In both examples you can now, edit, add, remove *.bks files on the share without the need of doing anything at the servers. Each night a new backup set
'will be created, and the old one deleted. Now what you should do, is to make sure you backup this share to tape or a suitable medium. Remember to store
'the medium in a secure way.
'SECURITY NOTE :
'It's highly recommended to set proper ntfs permission on the file structure, you should avoid using everyone full controll in NTFS. This can be done several
'ways, the easiest way would be through AG(G)(U)DLP (assumes a domain)
'Ex within a domain :
'Create a Domain Local group named : "Backup Change", add this group to ntfs permission on root at backup share with permission change. Create a global
'group named : "Backup", add this as member to "Backup Change". Add all the servers wich is going to run backup into "Backup" group (the servers need a
'reboot before effective). Only the server(s) itself is now able to read/write/delete to the root of backup$. If you're in a highly secure environment you
'may consider to set unique ntfs permission per server/subfolder.
'********************
'Scheduled Task Howto
'********************
'There are number of ways to schedule a backup, however the recommended secure way is to run the backup in context of System. To schedule a task to run
'in system context, you can use command line task scheduler, schtasks.
'Command line Examples :
'Add a job to run every day at 23:00 in context of system
'schtasks /create /tn "Daily Backup" /tr "C:\SBBS.vbs" /sc daily /st 23:00 /ru System
'Add a job to run every day at 23:00 in context of system, with path containing spaces
'schtasks /create /tn "Daily Backup" /tr "\"c:\program files\backup\SBBS.vbs\"" /sc daily /st 23:00 /ru System
'Delete scheduled task named "Daily Backup"
'schtasks /delete /tn "Daily Backup" /f
'Run scheduled task named "Daily Backup"
'schtasks /run /tn "Daily Backup"
'GUI :
'When specifying account credentials, use "NT AUTORITY\SYSTEM" w/blank password to run under system.
'SECURITY NOTE :
'Do should avoid schedule a task with username/password, this can easily be revealed.
'For a complete list of available commands see :
'[URL unfurl="true"]http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/ServerHelp/4dfd623a-5b57-4a35-8555-2dfb3292d1a9.mspx[/URL]
'*************
'Release Notes
'*************
'******************
'Ver 1.0 29/11/2005
'******************
' - Added, GNU License
' - Added, scheduled task GUI section
' - Changed, s_ParseArg, converted if statements to select case statement, more rational
'***********************
'Ver 1.0 RC 6 25/11/2005
'***********************
' - Corrected, bug in f_GetDayTimeDate function, f_GetDayTimeDate was misspelet (f_GetTimeDate) in first statement
'***********************
'Ver 1.0 RC 5 23/11/2005
'***********************
' - Corrected, Scheduled Task Howto Section
' - Changed, Sub s_SetVarValue, converted if statements to select case statment (Seems more rational).
'***********************
'Ver 1.0 RC 4 21/11/2005
'***********************
' - Added, Enterprise Howto section
' - Enhanced, Scheduled Task Howto Section
'***********************
'Ver 1.0 RC 3 21/11/2005
'***********************
' - Corrected, bug with sSDF variable. If provide in script (not as argument) entry was omitted
'***********************
'Ver 1.0 RC 2 18/11/2005
'***********************
' - Enhanced, loglevel full/debug split. Level 2 produce full log, Level 3 (New) produces debug (part of code executed) output.
' - Added, Scheduled Task howto section
'***********************
'Ver 1.0 RC 1 15/11/2005
'***********************
'- Initial Release Candidate
'******
'Prefix
'******
'a = Array
'b = Booalean
'c = Collection
'f_ = Function
'i = Integer
'o = Object
's = String
's_ = Sub
'CAPITAL = Constant
Option Explicit
'***************************************************************************************************************************
' DO NOT CHANGE CONSTANT
'***************************************************************************************************************************
Const MINWSHVER = 56 'Minimum Windows Host Script Version as integer
Const REQCSCRIPT = True 'Cscript engine required boolean value, true/false
Const REQENGINE = "cscript.exe" 'Name of executable engine
Const FORREADING = 1
Const FORWRITING = 2
Const FORAPPENDING = 8
Const SUCCESS = 0
Const ERRORL = 1
Const WARNING = 2
Const INFORMATION = 4
Const ABORT = "SBBS.vbs aborted with error(s). To determine cause, see logged information"
'***************************************************************************************************************************
'Check Requirements
If f_CheckRequirements <> True Then
s_ShowReq
End If
'Check syntax
If wscript.arguments.unnamed.count <> 0 Then
s_ShowSyntax
End If
Dim aNamedArg,aCompVar,aLog,aBks
Dim bFileLog,bUnbuffered
Dim sArg,sSDF,sFileLog,sStorage,sBks,sVerify,sRestrict,sHardwareCompression,sBackupType,sNTBackupLogLevel,sStorageRoot
Dim oShell,oFso,oRegEx
Dim i,iErr,iNumberOfBackup,iEventLogLevel,iFileLogLevel
'Create Shell object
Set oShell = Wscript.CreateObject("Wscript.Shell")
'Create FileSystemObject
Set oFso = CreateObject("Scripting.FileSystemObject")
'***************************************************************************************************************************
' Customizable variables
'***************************************************************************************************************************
'***********************
'Adjusted in script only
'***********************
iEventLogLevel = 1 'Loglevel eventlog 0 = None 1 = Success/Error 2 = Full 3 = Debug (Full/Debug to EventLog is not recommended due to amount of information and readablility)
iFileLogLevel = 2 'Loglevel File 0 = None 1 = Success/Error 2 = Full 3 = Debug
'************************
'In script or as argument
'************************
sSDF = "" 'Script definition file, can be passed as argument when executing script. Ex : sbbs.vbs /SDS:Filename
'*****************************************
'In script or definition file. If value is
'precent in both file and script, value
'from file takes precedence
'*****************************************
iNumberOfBackup = 0 'Number of backups to store in root directory (sStorage) 0 = Do not delete any backups WARNING! Read "Store a desired number of backups locally/remote" section before changing this number.
sFileLog = "" 'Path to logfile, leave blank to use same dir as storage
sStorage = oShell.CurrentDirectory & "\Store" 'Path to root of backup store. Default is scriptdir\store
sBks = oShell.CurrentDirectory 'Path to backup file. Either a file or a directory can be specified.
sVerify = "no" '{yes | no} Verifies the data after the backup is complete.
sRestrict = "no" '{yes | no} Restricts access to this tape to the owner or members of the Administrators group.
sHardwareCompression = "off" '{on | off} Uses hardware compression, if available, on the tape drive.
sBackupType = "normal" 'Specifies the backup type. It must be one of the following: normal, copy, differential, incremental, or daily.
bUnbuffered = False 'Run unbuffered backup True/False. See : [URL unfurl="true"]http://support.microsoft.com/kb/839272[/URL] or [URL unfurl="true"]http://www.microsoft.com/technet/itsolutions/msit/operations/exchbkup.mspx[/URL]
sNTBackupLogLevel = "f" 'NTBackup ONLY, {f | s | n} Specifies the type of log file: f=full, s=summary, n=none (no log file is created).
'***************************************************************************************************************************
' Main Code
'***************************************************************************************************************************
s_LogInterface Success, "[Main Code] Script Based Backup System Started Successfully."
'Bind to arguments
Set aNamedArg = Wscript.Arguments.Named
'Parse arguments in array
For each sArg in aNamedArg
s_ParseArg sArg, aNamedArg(sArg)
Next
If sSDF <> "" Then
If (oFso.FileExists(sSDF)) Then
s_GetValuesFromFile(sSDF)
Else
iEventLogLevel = 2
iFileLogLevel = 0
s_LogInterface ERRORL, "[Main Code] File : " & sSDF & " ,does not exist or cannot be accessed."
s_LogInterface ERRORL, ABORT
wscript.echo "Error! File : " & sSDF & ", does not exist or cannot be accessed."
wscript.quit
End If
End If
'Check sStorage path, abort if it doesn't exists and can't be created
sStorageRoot = sStorage
sStorage = sStorage & "\" & f_GetDayTimeDate
If f_CreateFolder(sStorage) <> True Then
s_LogInterface ERRORL, ABORT
wscript.quit
End If
'Switch start file log
bFileLog = True
If iFileLogLevel > 0 AND sFileLog = "" Then
sFileLog = sStorage & "Backup.log"
s_FileLog INFORMATION, "[Main Code] Path to logfile is determined to be : " & sFileLog
s_FileLog INFORMATION, "[Main Code] Write Log from array"
ElseIf iFileLogLevel > 0 Then
s_FileLog INFORMATION, "[Main Code] Write Log from array"
End If
s_GetBks(sBks)
If IsArray(aBks) Then
For i = 0 to UBound(aBks)
If Not IsEmpty(aBks(i)) Then
s_FileLog INFORMATION, "[Main Code] Call s_DoBackup, " & aBks(i)
s_DoBackup aBks(i)
End If
Next
Else
s_FileLog INFORMATION, "[Main Code] Call s_DoBackup, " & aBks(i)
s_DoBackup aBks(i)
End If
If iNumberOfBackup <> 0 Then
s_FileLog INFORMATION, "[Main Code] Call s_KeepOnly " & sStorageRoot & " " & iNumberOfBackup
s_KeepOnly sStorageRoot, iNumberOfBackup
End If
s_LogInterface Success, "[Main Code] Script Based Backup System Completed Successfully."
Set oShell = Nothing
Set aNamedArg = Nothing
Set oFso = Nothing
'***************************************************************************************************************************
' FUNCTION
'***************************************************************************************************************************
Function f_CheckRequirements()
'**********************************************
' Purpose : Check presence of script requiremts
' Input : None
' Return : True if requirements are fullfilled
' Uses : Constants defined below
'**********************************************
' Const MINWSHVER = 56 'Minimum Windows Host Script Version as integer
' Const REQCSCRIPT = True 'Cscript engine required boolean value, true/false
' Const REQENGINE = "cscript.exe" 'Name of executable engine
If REQCSCRIPT = True Then
f_CheckRequirements = CInt(ScriptEngineMajorVersion & ScriptEngineMinorVersion) >= MINWSHVER AND LCase(Right(wscript.fullname, 11)) = REQENGINE
Else
f_CheckRequirements = REQCSCRIPT = False AND CInt(ScriptEngineMajorVersion & ScriptEngineMinorVersion) >= MINWSHVER
End If
End Function
Function f_CreateFolder(s)
'*************************************************************
' Purpose : Create a folder, or a subset of folders based upon
' one path. Support both path and unc path. Ex :
' \\fqdn\share\my\path or D:\share\my\path. If only
' \\fqdn\share or D:\Share exists, function loop
' folder creation until path provided is created.
' Input : String Path to folder
' Return : True if folder exists or successfully created
'************************************************************
Dim sUnc,sResult
On Error Resume Next
Dim sFolder
If Right(s, 1) <> "\" Then
s = s & "\"
End If
'Check if path is UNC replace base path \\server\something with \
If Left(s, 2) = "\\" Then
sUNC = s
Set oRegEx = New RegExp
oRegEx.Pattern = "\\\\\w+\\\w+\$?\\"
sResult = oRegEx.Replace (s, "")
sUnc = Left(s, Len(s) - Len(sResult))
sFolder = sUnc
End If
Do Until sFolder = s
sFolder = Left(s, InStr(Len(sFolder) + 1, s, "\"))
If Not oFso.FolderExists(sFolder) Then
ofso.CreateFolder(sFolder)
If err.number <> 0 Then
s_LogInterface ERRORL, "[Function f_CreateFolder] Error creating : " & sFolder & ". The error was : " & err.description
Exit Function
End If
End If
Loop
f_CreateFolder = True
End Function
Function f_ExpandVar(s)
'***********************************************
' Purpose : Expand computervariables from string
' Input : String containing computervariabel
' Ouput : String with expanded variables
'***********************************************
f_ExpandVar = oShell.ExpandEnvironmentStrings(s)
End Function
Function f_GetDayTimeDate()
'****************************************************
' Purpose : Get Day,Date,Time
' Input : None
' Return : Current day of week + Date + Time
'****************************************************
f_GetDayTimeDate = WeekDayName(Weekday(Now, vbUseSystemDayOfWeek),,vbUseSystemDayOfWeek) & " " & Date & " "
If CInt(Hour(Now)) < 10 Then
f_GetDayTimeDate = f_GetDayTimeDate & "0" & Hour(Now)
Else
f_GetDayTimeDate = f_GetDayTimeDate & Hour(Now)
End If
If CInt(Minute(Now)) < 10 Then
f_GetDayTimeDate = f_GetDayTimeDate & "0" & Minute(Now)
Else
f_GetDayTimeDate = f_GetDayTimeDate & Minute(Now)
End If
End Function
'***************************************************************************************************************************
' SUB
'***************************************************************************************************************************
Sub s_DeleteFolder(s)
'*************************************
' Purpose : Delete folder
' Input : String (s) path to folder
'************************************
On Error Resume Next
err.clear
oFso.DeleteFolder s, True
If err.number <> 0 Then
s_LogInterface ERRORL, "[s_DeleteFolder] Failed to delete folder : " & s & ". The error was : " & err.description & " (" & err.number & ")"
Else
s_LogInterface SUCCESS, "[s_DeleteFolder] Folder : " & s & " was successfully deleted."
End If
End Sub
Sub s_DoBackup(s)
'*********************************************
' Purpose : Execute NTBackup
' Input : String (s) path to bks file
' Uses : Variables used in conjunction with
' NTBackup defined in script
'*********************************************
On Error Resume Next
Dim sBackup,sExecute,sJobName
'Get name of bks file from string(s)
s_LogInterface INFORMATION, "[Sub s_DoBackup] Parsing : " & s & " to determine name of bks file"
sBackup = Right(s, Len(s) - InStrRev(s, "\"))
s_LogInterface INFORMATION, "[Sub s_DoBackup] Filename is : " & sBackup & ". bks will be replaced with bkf"
'Get backup filename, replace bks w/bkf
Set oRegEx = New RegExp
oRegEx.IgnoreCase = True
oRegEx.Pattern = "bks"
sBackup = oRegEx.Replace(sBackup, "bkf")
s_LogInterface INFORMATION, "[Sub s_DoBackup] Backup filename is determined to be : " & sBackup
'Get backup job name, replace bkf w/""
sJobName = sBackup
oRegEx.Pattern = ".bkf"
sJobName = oRegEx.Replace(sJobName, "")
Set oRegEx = Nothing
s_LogInterface INFORMATION, "[Sub s_DoBackup] Backup job name is determined to be : " & sJobName
sExecute = "%SystemRoot%\System32\ntbackup backup " & """@" & s & """ /J """ & sJobName & """ /N """ & sJobName & """ /D """ & sJobName & """ /V:" & sVerify & " /R:" & sRestrict & " /RS:no /HC:off /M " & sBackupType & " /L:" & sNTBackupLogLevel & " /F """ & sStorage & sBackup & Chr(34)
If bUnbuffered Then
sExecute = sExecute & " /fu"
End If
s_LogInterface INFORMATION, "[Sub s_DoBackup] Executing backup using : " & sExecute
err.clear
oShell.Run sExecute, 1, True
If err.number <> 0 Then
s_LogInterface ERRORL, "[s_DoBackup] Backup executed with command : " & sExecute & " ended with Error. The error was : " & err.description
Else
s_LogInterface SUCCESS, "[s_DoBackup] Backup successfully executed with command : " & sExecute
s_LogInterface SUCCESS, "[s_DoBackup] Remember to check NTBackup log to verify backup process"
End If
End Sub
Sub s_EventLog(i, s)
'*************************************************************
' Purpose : Write Event to Eventlog.
' EventLog Level 0 = None 1 = Success/Error 2 = Full
' Input : i : Event type, Integer
' 0 SUCCESS
' 1 ERROR (Const ERRORL)
' 2 WARNING
' 4 INFORMATION
' s : Log message, String
'*************************************************************
'Const SUCCESS = 0
'Const ERRORL = 1
'Const WARNING = 2
'Const INFORMATION = 4
'0 = None 1 = Success/Error 2 = Full
Select Case iEventLogLevel
Case 1
Select Case i
Case SUCCESS
oShell.LogEvent i, s
Case ERRORL
oShell.LogEvent i, s
Case Else
Exit Sub
End Select
Case 2
Select Case i
Case SUCCESS
oShell.LogEvent i, s
Case ERRORL
oShell.LogEvent i, s
Case WARNING
oShell.LogEvent i, s
Case INFORMATION
oShell.LogEvent i, s
Case Else
Exit Sub
End Select
Case 3
Select Case i
Case SUCCESS
oShell.LogEvent i, s
Case ERRORL
oShell.LogEvent i, s
Case WARNING
oShell.LogEvent i, s
Case INFORMATION
oShell.LogEvent i, s
Case Else
Exit Sub
End Select
Case Else
Exit Sub
End Select
End Sub
Sub s_FileLog(i, s)
'*********************************************************************************************
' Purpose : Write Event to logfile. Build an array of events until path logfile is determined.
' If logfile can not be written. Events are redirected to eventlog.
' EventLog Level 0 = None 1 = Success/Error 2 = Full
' Input : i : Event type, Integer
' 0 SUCCESS
' 1 ERROR (Const ERRORL)
' 2 WARNING
' 4 INFORMATION
' s : Log message, String
' Use : bFileLog True/False when actually start logging to file
'*********************************************************************************************
'Const SUCCESS = 0
'Const ERRORL = 1
'Const WARNING = 2
'Const INFORMATION = 4
'0 = None 1 = Success/Error 2 = Full
On Error Resume Next
Dim iArr
Dim oLog
'Make sure errorlevel 0
err.clear
'Log to file if bFileLog flag is true
If bFileLog = True Then
Set oLog = oFso.OpenTextFile(sFileLog, FORAPPENDING, True)
If err.number <> 0 Then
iErr = err.number
'Clear error
err.clear
'Check if log folder exists, try to create
If f_CreateFolder(Left(sFileLog, InStrRev(sFileLog, "\"))) Then
Set oLog = oFso.OpenTextFile(sFileLog, FORAPPENDING, True)
Else
'Abort filelog operation if can't be written, switch to EventLog
iEventLogLevel = 2
iFileLogLevel = 0
err.Raise = iErr
s_LogInterface ERRORL, "[Sub s_FileLog] Error occured while writing to logfile : " & sFileLog & ". The error was : " & err.description
s_LogInterface WARNING, "[Sub s_FileLog] Events will permanently be redirected to eventlog. All events occured prior to this warning will now be written."
'Write events from array to eventlog
If IsArray(aLog) AND aLog(0) <> "" Then
For iArr = 0 To UBound(aLog)
s_LogInterface CInt(Left(aLog(iArr), 1)), Right(aLog(iArr), Len(aLog(iArr)) - 1)
Next
ReDim aLog(0)
End If
Exit Sub
End If
End If
'Write events from array to logfile
If IsArray(aLog) AND aLog(0) <> "" Then
For iArr = 0 To UBound(aLog)
oLog.WriteLine Right(aLog(iArr), Len(aLog(iArr)) - 1)
Next
ReDim aLog(0)
End If
Select Case iFileLogLevel
Case 1
Select Case i
Case SUCCESS
oLog.WriteLine Now & " SUCCESS " & s
Case ERRORL
oLog.WriteLine Now & " ERROR " & s
Case Else
Exit Sub
End Select
Case 2
Select Case i
Case SUCCESS
oLog.WriteLine Now & " SUCCESS " & s
Case ERRORL
oLog.WriteLine Now & " ERROR " & s
Case WARNING
oLog.WriteLine Now & " WARNING " & s
Case INFORMATION
oLog.WriteLine Now & " INFORMATION " & s
Case Else
Exit Sub
End Select
Case 3
Select Case i
Case SUCCESS
oLog.WriteLine Now & " SUCCESS " & s
Case ERRORL
oLog.WriteLine Now & " ERROR " & s
Case WARNING
oLog.WriteLine Now & " WARNING " & s
Case INFORMATION
oLog.WriteLine Now & " INFORMATION " & s
Case Else
Exit Sub
End Select
Case Else
Exit Sub
End Select
oLog.close
Set oLog = Nothing
Else
'Log to array while path to logfile determined
If IsArray(aLog) Then
iArr = UBound(aLog) + 1
ReDim Preserve aLog(iArr)
Else
ReDim aLog(1)
End If
Select Case iFileLogLevel
Case 1
Select Case i
Case SUCCESS
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " SUCCESS " & s
Case ERRORL
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " ERROR " & s
Case Else
Exit Sub
End Select
Case 2
Select Case i
Case SUCCESS
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " SUCCESS " & s
Case ERRORL
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " ERROR " & s
Case WARNING
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " WARNING " & s
Case INFORMATION
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " INFORMATION " & s
Case Else
Exit Sub
End Select
Case 3
Select Case i
Case SUCCESS
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " SUCCESS " & s
Case ERRORL
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " ERROR " & s
Case WARNING
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " WARNING " & s
Case INFORMATION
ReDim Preserve aLog(iArr)
aLog(iArr) = i & Now & " INFORMATION " & s
Case Else
Exit Sub
End Select
Case Else
Exit Sub
End Select
End If
End Sub
Sub s_GetBks(s)
'************************************************************
' Purpose : Check path to *.bks file(s). Determine if path is
' a file or dir. If path is dir, every .bks within
' dir is added to an array (aBks)
' Input : String (s) path to file/dir
' Use : sBks (String)
'************************************************************
Dim cFiles
' Dim i
Dim oFolder,oFile
s_LogInterface Information, "[Sub s_GetBks] Analyzing path to *.bks. Provided path is : " & s
'Check if sBks is a file
If (oFso.FileExists(s)) Then
s_LogInterface Information, "[Sub s_GetBks] Analyze done. Path provided is determined to be only one file. File is : " & s
'Check if sBks is a folder
ElseIf (oFso.FolderExists(s)) Then
s_LogInterface Information, "[Sub s_GetBks] Analyze done. Path provided is determined to be a directory. Start sub analyze of " & s
Set oFolder = oFso.GetFolder(s)
Set cFiles = oFolder.Files
ReDim aBks(0)
i = 0
For Each oFile In cFiles
s_LogInterface Information, "[Sub s_GetBks] Parsing : " & oFile.Path
If LCase(Right(oFile.Path, 4)) = ".bks" Then
i = i + 1
s_LogInterface SUCCESS, "[Sub s_GetBks] Backup file found, path : " & oFile.Path
ReDim Preserve aBks(i)
aBks(i) = oFile.Path
End If
Next
Else
s_LogInterface ERRORL, "[Sub s_GetBks] Could not determine if " & s & " is a path or a file"
s_LogInterface ERRORL, ABORT
wscript.quit
End If
End Sub
Sub s_GetValuesFromFile(s)
'***********************************************************
' Purpose : Read variable values from script definition file
' Assign value(s) to variabel(s)
' Input : Path of file
'***********************************************************
Dim oSDF
Dim sLine,sVar,sVal
On Error Resume Next
'Make sure errorlevel equal 0
err.clear
'Open definition file
Set oSDF = oFso.OpenTextFile(s, FORREADING)
If err.number <> SUCCESS Then
s_LogInterface ERRORL, "[Sub s_GetValuesFromFile] Error occured reading : " & s & ". The error was : " & err.description
s_LogInterface ERRORL, ABORT
wscript.quit
Else
s_LogInterface SUCCESS, "[Sub s_GetValuesFromFile] Start reading : " & s
End If
'Read definition file
Do until oSDF.AtEndOfStream = True
sLine = LCase(oSDF.ReadLine)
'Skip lines beginning with '
If Left(sLine, 1) <> "'" AND sLine <> "" Then
s_LogInterface INFORMATION, "[Sub s_GetValuesFromFile] Parsing string : " & sLine
If InStr(sLine, "=") Then
sVar = Left(sLine, InStr(sLine, "=") -1)
sVal = Mid(sLine, InStr(sLine, "=") +1)
s_LogInterface INFORMATION, "[Sub s_GetValuesFromFile] String Parsed. Variable = " & sVar & ", Value = " & sVal & "."
s_SetVarValue sVar, sVal
Else
s_LogInterface WARNING, "[Sub s_GetValuesFromFile] Invalid string in : " & s & " . Invalid string : " & sLine
End If
End If
Loop
End Sub
Sub s_KeepOnly(s, i)
'***************************************************
' Purpose : Delete obsolete folders based upon date.
' Newest folders are kept.
' Input : String (s) Path to root of folders
' Integer (i) Number of folders to keep
'***************************************************
On Error Resume Next
Dim aDate
Dim oFldr,oSubFldr
Dim cFldr
Dim iCnt
Dim n,m,temp
Set oFldr = oFso.GetFolder(s)
If err.number <> 0 Then
s_LogInterface ERRORL, "[s_KeepOnly] An Error occured connecting to : " & s & " old backupfiles must be deleted manually."
Exit Sub
Else
s_LogInterface INFORMATION, "[s_KeepOnly] Connected to : " & s
End If
Set cFldr = oFldr.SubFolders
If err.number <> 0 Then
s_LogInterface ERRORL, "[s_KeepOnly] An Error occured connecting to SubFolders of : " & s & " old backupfiles must be deleted manually."
Exit Sub
Else
s_LogInterface INFORMATION, "[s_KeepOnly] Connected to : " & s
End If
'Check if number of folders greater than i
If oFldr.SubFolders.Count <= i Then
s_LogInterface INFORMATION, "[s_KeepOnly] Number of folders in root is : " & oFldr.SubFolders.Count & ". Number is less than or equal to : " & i & " wich is the number of backups to keep."
Exit Sub
End If
s_LogInterface INFORMATION, "[s_KeepOnly] Number of folders in root is : " & oFldr.SubFolders.Count & ". Number is greater than : " & i & " wich is the number of backups to keep."
'ReDim array to number of folders
ReDim aDate(oFldr.SubFolders.Count -1)
s_LogInterface INFORMATION, "[s_KeepOnly] Creating array with fixed size : " & oFldr.SubFolders.Count -1 & ". Adding date of folders to array"
iCnt = 0
'Add date creation of all folders to array
For Each oSubFldr in cFldr
s_LogInterface INFORMATION, "[s_KeepOnly] aDate(" & iCnt & ") = " & oSubFldr.DateCreated & " (Path : " & oSubFldr.Path & ")"
aDate(iCnt) = oSubFldr.DateCreated
iCnt = iCnt + 1
Next
'Sorting array by date, ascent sort order (The famous bubble sort)
s_LogInterface INFORMATION, "[s_KeepOnly] Sorting dates in array, ascent sort order"
For n = 0 to UBound(aDate) -1
For m = n+1 to UBound(aDate)
If aDate(m) < aDate(n) Then
temp = aDate(m)
aDate(m) = aDate(n)
aDate(n) = temp
End If
Next
Next
'Just logging
s_LogInterface INFORMATION, "[s_KeepOnly] Array sorted, result in ascent order : "
For iCnt = 0 To UBound(aDate)
s_LogInterface INFORMATION, "[s_KeepOnly] aDate(" & iCnt & ") = " & aDate(iCnt)
Next
'Cut array, keep (i) rows with date of folders wich is going to be deleted
ReDim Preserve aDate(UBound(aDate) -i)
s_LogInterface INFORMATION, "[s_KeepOnly] Array aDate cut, remaing rows are : "
'Even more logging (those debuggers ;))
For iCnt = 0 To UBound(aDate)
s_LogInterface INFORMATION, "[s_KeepOnly] aDate(" & iCnt & ") = " & aDate(iCnt)
Next
s_LogInterface INFORMATION, "[s_KeepOnly] Start deleting folders..."
For Each oSubFldr in cFldr
For iCnt = 0 To UBound(aDate)
If oSubFldr.DateCreated = aDate(iCnt) Then
s_LogInterface INFORMATION, "[s_KeepOnly] aDate(" & iCnt & ") = " & aDate(iCnt) & " matches DateCreated on folder : " & oSubFldr.Path & " (Date=" & oSubFldr.DateCreated & ")"
s_DeleteFolder oSubFldr.Path
Exit For
End If
Next
Next
End Sub
Sub s_LogInterface(i, s)
'***********************************************************************************************
' Purpose : Log interface, write various type of events to different formats, NT Event, File etc
' Easyly extend logging into other formats, ex mail,xml etc.
' Input : i : Event type, Integer 0 = None 1 = Success/Error 2 = Full
' s : Log message, String
'***********************************************************************************************
If iEventLogLevel = 1 or iEventLogLevel = 2 Then
Set oRegEx = New RegExp
oRegEx.Pattern = "\[.*\] "
s = oRegEx.Replace (s, "")
s_EventLog i, s
Set oRegEx = Nothing
End If
If iEventLogLevel = 3 Then
s_EventLog i, s
wscript.echo s
End If
If iFileLogLevel = 1 or iFileLogLevel = 2 Then
Set oRegEx = New RegExp
oRegEx.Pattern = "\[.*\] "
s = oRegEx.Replace (s, "")
s_FileLog i, s
Set oRegEx = Nothing
End If
If iFileLogLevel = 3 Then
wscript.echo s
s_FileLog i, s
End If
End Sub
Sub s_SetVarValue(sVar, sVal)
'***********************************************************
' Purpose : Set variable values and expand computervariables
' Input : sVar : String, variable name
' sVal : String, value of variable
'************************************************************
On Error Resume Next
If InStr(sVal, "%") Then
s_LogInterface INFORMATION, "[Sub S_SetVarValue] Variable : " & sVal & " is a computer variable. Now expanding : " & sVar
sVal = f_ExpandVar(sVal)
s_LogInterface INFORMATION, "[Sub S_SetVarValue] Variable : " & sVal & " expanded to : " & sVar
End If
s_LogInterface INFORMATION, "[Sub S_SetVarValue] Assign : " & sVal & " to : " & sVar
Select Case sVar
Case "inumberofbackup"
iNumberOfBackup = CInt(sVal)
Case "sfilelog"
sfilelog = sVal
Case "sstorage"
sStorage = sVal
Case "sbks"
sBks = sVal
Case "bunbuffered"
bUnbuffered = sVal
Case "sverify"
sVerify = sVal
Case "srestrict"
sRestrict = sVal
Case "shardwarecompression"
sHardWareCompression = sVal
Case sVar = "sbackuptype"
sBackupType = sVal
Case "ntbackuploglevel"
sNTBackupLogLevel = sVal
Case Else
Exit Sub
End Select
s_LogInterface SUCCESS, "[Sub S_SetVarValue] Assigning : " & sVal & " to : " & sVar
End Sub
Sub s_ShowReq
'**********************************
' Purpose: Show script requirements
'**********************************
wscript.echo "This script require cscript engine. Invoke script by using : " & VbNewLine & _
"CScript.exe SBBS.vbs" & VbNewLine &_
"To set CScript as default engine, type this at command line : " & VbNewLine & _
"CScript.exe //H:CScript" & VbNewLine &_
"Windows Script Host ver. 5.6 or above is required." & VbNewLine &_
"To determine your version, type cscript at command prompt and press enter." & VbNewLine &_
"The script must be exectuted in context of System or Admin"
wscript.quit
End Sub
Sub s_ShowSyntax
'*******************************
' Purpose: Show syntax of script
'*******************************
s_ShowCopyRight()
wscript.echo "SBBS.vbs or SBBS.vbs [/SDF:Filename]" & VbNewLine
wscript.echo "/SDF:Filename.txt Script Definition File. Use full path."
wscript.echo "/Req Show requirements"
wscript.echo "/License Show License"
wscript.echo "/? or /Help Show help"
wscript.echo "/Copyright Show CopyRight"
wscript.quit
End Sub
Sub s_ShowCopyRight()
'************************
' Purpose: Show CopyRight
'************************
wscript.echo "Script Based Backup System Ver. 1.0, Copyright (C) 2005 Nils-Erik Auråker." & vbNewLine & vbNewLine &_
"Script Based Backup System Ver. 1.0 comes with ABSOLUTELY NO WARRANTY;" & vbNewLine &_
"This is free software, and you are welcome to redistribute it under certain" & vbNewLine &_
"conditions; type SBBS.vbs /License for details." & vbNewLine
End Sub
Sub s_ShowLicense()
'*************************
' Purpose: Show GNU Licens
'*************************
wscript.echo vbNewLine & vbNewLine
wscript.echo "TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION" & vbNewLine
wscript.echo "0. This License applies to any program or other work which contains a notice" & vbNewLine &_
"placed by the copyright holder saying it may be distributed under the terms of" & vbNewLine &_
"this General Public License. The " & Chr(34) & "Program" & Chr(34) & ", below, refers to any such program" & vbNewLine &_
"or work, and a " & Chr(34) & "work based on the Program" & Chr(34) & " means either the Program or any" & vbNewLine &_
"derivative work under copyright law: that is to say, a work containing the" & vbNewLine &_
"Program or a portion of it, either verbatim or with modifications and/or" & vbNewLine &_
"translated into another language. (Hereinafter, translation is included without" & vbNewLine &_
"limitation in the term " & Chr(34) & "modification" & Chr(34) & ".) Each licensee is addressed as " & Chr(34) & "you" & Chr(34) & "." & vbNewLine
wscript.echo "Activities other than copying, distribution and modification are not covered by" & vbNewLine &_
"this License; they are outside its scope. The act of running the Program is not" & vbNewLine &_
"restricted, and the output from the Program is covered only if its contents" & vbNewLine &_
"constitute a work based on the Program (independent of having been made by" & vbNewLine &_
"running the Program). Whether that is true depends on what the Program does." & vbNewLine & vbNewLine
wscript.echo "1. You may copy and distribute verbatim copies of the Program's source code" & vbNewLine &_
"as you receive it, in any medium, provided that you conspicuously and" & vbNewLine &_
"appropriately publish on each copy an appropriate copyright notice and" & vbNewLine &_
"disclaimer of warranty; keep intact all the notices that refer to this License" & vbNewLine &_
"and to the absence of any warranty; and give any other recipients of the" & vbNewLine &_
"Program a copy of this License along with the Program." & vbNewLine
wscript.echo "You may charge a fee for the physical act of transferring a copy, and you may" & vbNewLine &_
"at your option offer warranty protection in exchange for a fee." & vbNewLine & vbNewLine
wscript.echo "2. You may modify your copy or copies of the Program or any portion of it, thus" & vbNewLine &_
"forming a work based on the Program, and copy and distribute such modifications" & vbNewLine &_
"or work under the terms of Section 1 above, provided that you also meet all of" & vbNewLine &_
"these conditions:" & vbNewLine
wscript.echo "a) You must cause the modified files to carry prominent notices stating that" & vbNewLine &_
"you changed the files and the date of any change." & vbNewLine
wscript.echo "b) You must cause any work that you distribute or publish, that in whole or" & vbNewLine &_
"in part contains or is derived from the Program or any part thereof, to be" & vbNewLine &_
"licensed as a whole at no charge to all third parties under the terms of this" & vbNewLine &_
" License." & vbNewLine
wscript.echo "c) If the modified program normally reads commands interactively when run, you" & vbNewLine &_
"must cause it, when started running for such interactive use in the most" & vbNewLine &_
"ordinary way, to print or display an announcement including an appropriate" & vbNewLine &_
"copyright notice and a notice that there is no warranty (or else, saying that" & vbNewLine &_
"you provide a warranty) and that users may redistribute the program under these" & vbNewLine &_
"conditions, and telling the user how to view a copy of this License. (Exception" & vbNewLine &_
": if the Program itself is interactive but does not normally print such an" & vbNewLine &_
"announcement, your work based on the Program is not required to print an" & vbNewLine &_
"announcement.)" & vbNewLine
wscript.echo "These requirements apply to the modified work as a whole. If identifiable" & vbNewLine &_
"sections of that work are not derived from the Program, and can be reasonably" & vbNewLine &_
"considered independent and separate works in themselves, then this License," & vbNewLine &_
"and its terms, do not apply to those sections when you distribute them as" & vbNewLine &_
"separate works. But when you distribute the same sections as part of a whole" & vbNewLine &_
"which is a work based on the Program, the distribution of the whole must be" & vbNewLine &_
"on the terms of this License, whose permissions for other licensees extend" & vbNewLine &_
"to the entire whole, and thus to each and every part regardless of who wrote" & vbNewLine &_
"it." & vbNewLine
wscript.echo "Thus, it is not the intent of this section to claim rights or contest your" & vbNewLine &_
"rights to work written entirely by you; rather, the intent is to exercise the" & vbNewLine &_
"right to control the distribution of derivative or collective works based on" & vbNewLine &_
"the Program." & vbNewLine
wscript.echo "In addition, mere aggregation of another work not based on the Program with" & vbNewLine &_
"the Program (or with a work based on the Program) on a volume of a storage" & vbNewLine &_
"or distribution medium does not bring the other work under the scope of this" & vbNewLine &_
"License." & vbNewLine
wscript.echo "3. You may copy and distribute the Program (or a work based on it, under" & vbNewLine &_
"Section 2) in object code or executable form under the terms of Sections 1 and" & vbNewLine &_
"2 above provided that you also do one of the following:" & vbNewLine
wscript.echo "a) Accompany it with the complete corresponding machine-readable source code," & vbNewLine &_
"which must be distributed under the terms of Sections 1 and 2 above on a medium" & vbNewLine &_
"customarily used for software interchange; or," & vbNewLine
wscript.echo "b) Accompany it with a written offer, valid for at least three years, to give" & vbNewLine &_
"any third party, for a charge no more than your cost of physically performing" & vbNewLine &_
"source distribution, a complete machine-readable copy of the corresponding" & vbNewLine &_
"source code, to be distributed under the terms of Sections 1 and 2 above on a" & vbNewLine &_
"medium customarily used for software interchange; or," & vbNewLine
wscript.echo "c) Accompany it with the information you received as to the offer to distribute" & vbNewLine &_
"corresponding source code. (This alternative is allowed only for noncommercial" & vbNewLine &_
"distribution and only if you received the program in object code or executable" & vbNewLine &_
"form with such an offer, in accord with Subsection b above.)" & vbNewLine
wscript.echo "The source code for a work means the preferred form of the work for making" & vbNewLine &_
"modifications to it. For an executable work, complete source code means all the" & vbNewLine &_
"source code for all modules it contains, plus any associated interface" & vbNewLine &_
"definition files, plus the scripts used to control compilation and installation" & vbNewLine &_
"of the executable. However, as a special exception, the source code distributed" & vbNewLine &_
"need not include anything that is normally distributed (in either source or" & vbNewLine &_
"binary form) with the major components (compiler, kernel, and so on) of the" & vbNewLine &_
"operating system on which the executable runs, unless that component itself" & vbNewLine &_
"accompanies the executable." & vbNewLine
wscript.echo "If distribution of executable or object code is made by offering access to copy" & vbNewLine &_
"from a designated place, then offering equivalent access to copy the source" & vbNewLine &_
"code from the same place counts as distribution of the source code, even though" & vbNewLine &_
"third parties are not compelled to copy the source along with the object code." & vbNewLine
wscript.echo "4. You may not copy, modify, sublicense, or distribute the Program except as" & vbNewLine &_
"expressly provided under this License. Any attempt otherwise to copy, modify," & vbNewLine &_
"sublicense or distribute the Program is void, and will automatically terminate" & vbNewLine &_
"your rights under this License. However, parties who have received copies, or" & vbNewLine &_
"rights, from you under this License will not have their licenses terminated so" & vbNewLine &_
"long as such parties remain in full compliance." & vbNewLine
wscript.echo "5. You are not required to accept this License, since you have not signed it." & vbNewLine &_
"However, nothing else grants you permission to modify or distribute the Program" & vbNewLine &_
"or its derivative works. These actions are prohibited by law if you do not" & vbNewLine &_
"accept this License. Therefore, by modifying or distributing the Program (or" & vbNewLine &_
"any work based on the Program), you indicate your acceptance of this License to" & vbNewLine &_
" do so, and all its terms and conditions for copying, distributing or modifying" & vbNewLine &_
"the Program or works based on it." & vbNewLine
wscript.echo "6. Each time you redistribute the Program (or any work based on the Program)," & vbNewLine &_
"the recipient automatically receives a license from the original licensor to" & vbNewLine &_
"copy, distribute or modify the Program subject to these terms and conditions." & vbNewLine &_
"You may not impose any further restrictions on the recipients' exercise of the" & vbNewLine &_
"rights granted herein. You are not responsible for enforcing compliance by" & vbNewLine &_
"third parties to this License." & vbNewLine
wscript.echo "7. If, as a consequence of a court judgment or allegation of patent" & vbNewLine &_
"infringement or for any other reason (not limited to patent issues), conditions" & vbNewLine &_
"are imposed on you (whether by court order, agreement or otherwise) that" & vbNewLine &_
"contradict the conditions of this License, they do not excuse you from the" & vbNewLine &_
"conditions of this License. If you cannot distribute so as to satisfy" & vbNewLine &_
"simultaneously your obligations under this License and any other pertinent" & vbNewLine &_
"obligations, then as a consequence you may not distribute the Program at all." & vbNewLine &_
"For example, if a patent license would not permit royalty-free redistribution" & vbNewLine &_
"of the Program by all those who receive copies directly or indirectly through" & vbNewLine &_
"you, then the only way you could satisfy both it and this License would be to" & vbNewLine &_
"refrain entirely from distribution of the Program." & vbNewLine
wscript.echo "If any portion of this section is held invalid or unenforceable under any" & vbNewLine &_
"particular circumstance, the balance of the section is intended to apply and" & vbNewLine &_
"the section as a whole is intended to apply in other circumstances." & vbNewLine
wscript.echo "It is not the purpose of this section to induce you to infringe any patents or" & vbNewLine &_
"other property right claims or to contest validity of any such claims; this" & vbNewLine &_
"section has the sole purpose of protecting the integrity of the free software" & vbNewLine &_
"distribution system, which is implemented by public license practices. Many" & vbNewLine &_
"people have made generous contributions to the wide range of software" & vbNewLine &_
"distributed through that system in reliance on consistent application of that" & vbNewLine &_
"system; it is up to the author/donor to decide if he or she is willing to" & vbNewLine &_
"distribute software through any other system and a licensee cannot impose that" & vbNewLine &_
"choice." & vbNewLine
wscript.echo "This section is intended to make thoroughly clear what is believed to be a" & vbNewLine &_
"consequence of the rest of this License." & vbNewLine
wscript.echo "8. If the distribution and/or use of the Program is restricted in certain" & vbNewLine &_
"countries either by patents or by copyrighted interfaces, the original" & vbNewLine &_
"copyright holder who places the Program under this License may add an explicit" & vbNewLine &_
"geographical distribution limitation excluding those countries, so that" & vbNewLine &_
"distribution is permitted only in or among countries not thus excluded. In such" & vbNewLine &_
"case, this License incorporates the limitation as if written in the body of" & vbNewLine &_
"this License." & vbNewLine
wscript.echo "9. The Free Software Foundation may publish revised and/or new versions of the" & vbNewLine &_
"General Public License from time to time. Such new versions will be similar in" & vbNewLine &_
"spirit to the present version, but may differ in detail to address new" & vbNewLine &_
"problems or concerns." & vbNewLine
wscript.echo "Each version is given a distinguishing version number. If the Program specifies" & vbNewLine &_
"a version number of this License which applies to it and " & Chr(34) & "any later version" & Chr(34) & "," & vbNewLine &_
"you have the option of following the terms and conditions either of that" & vbNewLine &_
"version or of any later version published by the Free Software Foundation. If" & vbNewLine &_
"the Program does not specify a version number of this License, you may choose" & vbNewLine &_
"any version ever published by the Free Software Foundation." & vbNewLine
wscript.echo "10. If you wish to incorporate parts of the Program into other free programs" & vbNewLine &_
"whose distribution conditions are different, write to the author to ask for" & vbNewLine &_
"permission. For software which is copyrighted by the Free Software Foundation," & vbNewLine &_
"write to the Free Software Foundation; we sometimes make exceptions for this." & vbNewLine &_
"Our decision will be guided by the two goals of preserving the free status of" & vbNewLine &_
"all derivatives of our free software and of promoting the sharing and reuse of" & vbNewLine &_
"software generally." & vbNewLine
wscript.echo "NO WARRANTY" & vbNewLine
wscript.echo "11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR" & vbNewLine &_
"THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE" & vbNewLine &_
"STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE" & vbNewLine &_
"PROGRAM " & Chr(34) & "AS IS" & Chr(34) & " WITHOUT WARRANTY OF ANY KIND, EITHER" & vbNewLine &_
"EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF" & vbNewLine &_
"MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE" & vbNewLine &_
"QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE" & vbNewLine &_
"DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION." & vbNewLine
wscript.echo "12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL" & vbNewLine &_
"ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE" & vbNewLine &_
"PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY" & vbNewLine &_
"GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR" & vbNewLine &_
"INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA" & vbNewLine &_
"BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A" & vbNewLine &_
"FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER" & vbNewLine &_
"OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES." & vbNewLine
wscript.echo "END OF TERMS AND CONDITIONS"
wscript.quit
End Sub
Sub s_ParseArg(sArg, s)
'*******************************************************
' Purpose : Parse arguments passed from aNamedArg array.
' Input : sArg : Name of argument, String
' s : Value of argument, String
'*******************************************************
sArg = UCase(sArg)
Select Case sArg
Case "SDF"
sSDF = s
Case "REQ"
s_ShowReq
Case "LICENSE"
s_ShowLicense
Case "?"
s_ShowSyntax
Case "HELP"
s_ShowSyntax
Case Else
s_ShowSyntax
End Select
End Sub
Sample definition file :
Code:
'Number of backups to store in root directory (sStorage) 0 = Do not delete any backups WARNING! Read "Store a desired number of backups locally/remote" section before changing this number.
'iNumberOfBackup=1
'Path to logfile, leave blank (or commented out) to use same dir as storage
'sFileLog=%ProgramFiles%\Backup\Store\Backup.log
'Path to root of backup store. Default in script is scriptdir\store
sStorage=%ProgramFiles%\Backup\Store
'Path to backup file. Either a file or a directory can be specified.
sBks=%ProgramFiles%\Backup
'{yes | no} Verifies the data after the backup is complete.
sVerify=no
'{yes | no} Restricts access to this tape to the owner or members of the Administrators group.
sRestrict=no
'{on | off} Uses hardware compression, if available, on the tape drive.
sHardwareCompression=off
'Specifies the backup type. It must be one of the following: normal, copy, differential, incremental, or daily.
sBackupType=normal
'{True | False} Run unbuffered backup. See : [URL unfurl="true"]http://support.microsoft.com/kb/839272[/URL] or
'[URL unfurl="true"]http://www.microsoft.com/technet/itsolutions/msit/operations/exchbkup.mspx[/URL]
bUnbuffered=false
'NTBackup ONLY, {f | s | n} Specifies the type of log file: f=full, s=summary, n=none (no log file is created).
sNTBackupLogLevel="f"