Backup a VisualSVN Repository with VBScript
Last week I had to make a backup of a VisualSVN Repository and trying backup each site individually would have taken me forever. so after a little digging on Google found this great little VB script file to backup all the repository's on a Windows server.
for some reason I cant find the original forum post were i found the script to give the original author credit for his work. but here is the script for anyone who would like to use it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | 'Save File as : BackupSVN.vbs Option Explicit 'loop through folders and use svnadmin to dump all repos to a backuplocation 'trying to run this type of command for each repo 'C:\Program Files\VisualSVN Server\bin>svnadmin dump C:\svnrepos\MyProject > \\nas\folder\MyProject.bak Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Dim scriptPath, argCount, namedArgs scriptPath = replace(wscript.scriptfullname, wscript.scriptname, "") argCount= WScript.Arguments.Count Set namedArgs = WScript.Arguments.Named Dim fso, svnExePath, repoFolderPath, backupFolderPath Set fso = CreateObject("Scripting.FileSystemObject") '************* uncomment or edit for the correct path to svnadmin**************** svnExePath = "D:\SVN_Server\bin\svnadmin.exe" '************* edit this line to match your backup destination**************** backupFolderPath = "D:\SvnBackup" 'only needs editing if you don't put it into the repos folder repoFolderPath = scriptPath If namedArgs.Exists("help") Or namedArgs.Exists("?") Then Wscript.Echo "Usage: " Wscript.Echo "/svn:<svn> is optional to enter the svnadmin executable full path & name." Wscript.Echo " - default is " & svnExePath Wscript.Echo Wscript.Echo "/repos:<repos> is optional to select the svn repositories folder." Wscript.Echo " - default is " & repoFolderPath Wscript.Echo Wscript.Echo "/backup:<backup> is optional to select the svn backupdestination folder." Wscript.Echo " - default is " & backupFolder Wscript.Quit End If If namedArgs.Exists("svn") Then svnExePath = Trim(namedArgs.Item("svn")) End If If namedArgs.Exists("repos") Then repoFolderPath= Trim(namedArgs.Item("path")) End If If namedArgs.Exists("backup") Then backupFolderPath= Trim(namedArgs.Item("backup")) End If DumpSvnRepos svnExePath, repoFolderPath, backupFolderPath 'create and execute a batch file to dump all of the repos 'for some reason running the dump command directly will not work Function DumpSvnRepos(svnExePath, rootFolderPath, backupFolderPath) Dim rootFolder, subFolders, folder, file Dim logFileName, text Set rootFolder = fso.GetFolder(rootFolderPath) Set subFolders = rootFolder.SubFolders logFileName = Replace(wscript.ScriptFullName, ".vbs", ".bat") Set file = fso.OpenTextFile (logFileName, ForAppending, True) For Each folder in subFolders Wscript.Echo folder.Name text = Chr(34) & svnExePath & Chr(34) & " dump " & Chr(34) & repoFolderPath & "\" & folder.Name & Chr(34) & " > " & Chr(34) & backupFolderPath & "\" & folder.Name & ".bak" & Chr(34) file.WriteLine(text) Next file.Close Wscript.Echo "Batch file created: " & logFileName runCommand logFileName End Function Function runCommand(commandLine) Dim shell, errorCode Set shell = CreateObject("WScript.shell") shell.Run commandLine, ,True 'command, WindowType, WaitOnReturn errorCode = err.Number If errorCode > 0 Then wscript.echo "runCommand Error " & err.Number & ": " & VbCrLf & commandLine & VbCrLf & err.Description logText "runCommand Error " & err.Number & ": " & vbTab & commandLine & vbTab & err.Description Err.Clear Else logText "runCommand Success : " & vbTab & commandLine End If runCommand = errorCode End Function Sub LogText(text) Dim file, logFile logFile = Replace(wscript.ScriptFullName, ".vbs", ".txt") Set file = fso.OpenTextFile (logFile, ForAppending , True) ' Writes Text every time you run this VBScript file.WriteLine(text) file.Close End Sub |
Classic ASP SmarterTrack Webservice Interface

In my first SmarterTrack article I discussed the building a Login Provider web service, In this article I am going to show you a simple implementation of of using Classic ASP to communicate with the SmarterTrack web services to enhance your current app. by proving a few simple methods for creating a ticket from a classic ASP page.
A perfect example would be a classic ASP shopping cart that displays past orders to a customer and you want to provide a quick way for your customers to create a customer service ticket without entering the customer service portal.
The example here was used with version 5.0.3813 of SmarterTrack installed locally on my machine. And you will also need the Microsoft 'SOAP Toolkit 3.0', it can be downloaded from Microsoft @ http://www.microsoft.com/downloads/details.aspx?familyid=c943c0dd-ceec-4088-9753-86f052ec8450&displaylang=en.
This is a simple method and does not provide any error handling or business logic, Ill leave that up to you to implement. this is only meant to show you the proper way to call the SmarterTrack web service's from classic ASP.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | <% Class SmarterTrack_svcTicket '##################################################################################################### '################################################################# 'VERY IMPORTANT: When attempting to get this class to work we were getting the following error: '################################################################# 'WSDLReader error '80020009' 'WSDLReader:Loading of the WSDL file failed HRESULT=0x80040154: Class not registered - 'Client:An unanticipated error occurred during the processing of this request. HRESULT=0x80040154: Class not registered 'The error occurred the following line in "Class_Initialize": 'oSOAP.mssoapinit WebserviceURL & "svcTickets.asmx?WSDL", "svcTickets" 'To get this SOAP functionality to work, make sure that the following is installed on the machine (this fixed our error above): '1) SOAP Toolkit 3.0 (http://www.microsoft.com/downloads/en/details.aspx?FamilyId=C943C0DD-CEEC-4088-9753-86F052EC8450&displaylang=en) '2) MSXML 4.0 Service Pack 2 (Microsoft XML Core Services) ' - http://www.microsoft.com/downloads/en/details.aspx?familyid=3144b72b-b4f2-46da-b4b6-c5d7485f2b42&displaylang=en ' - install msxml.msi 'Private Declarations Private oSOAP Private svcTicketsWDSL Private svcTicketsNamespace Private svcResponse 'Public Declarations Public AgentUserName Public AgentPassword Public WebserviceURL Public WebServiceTimeout Public TicketNumber Public Result Public ResultCode Public RequestResult 'Create & Destroy Methods Private Sub Class_Initialize WebserviceURL = "http://localhost:9996/services/" 'Default Value (DEV Address) AgentUserName = "admin" AgentPassword = "admin" WebServiceTimeout = 10000 '10 seconds Set oSOAP = Server.CreateObject("MSSOAP.SoapClient30") oSOAP.ClientProperty("ServerHTTPRequest") = True oSOAP.mssoapinit WebserviceURL & "svcTickets.asmx?WSDL", "svcTickets" oSoap.ConnectorProperty("Timeout") = WebServiceTimeout End Sub Private Sub Class_Terminate Set oSOAP = Nothing End Sub 'Subroutines Public Function CreateTicket(byVal intDeptID,byVal UserEmailAddress, byVal Subject, byVal MessageBody, byVal SendAutoRespond) Response.Write "<hr>CreateTicket()<br>" Set svcResponse = oSOAP.CreateTicket(AgentUserName, AgentPassword, intDeptID, UserEmailAddress, Subject, MessageBody , false, SendAutoRespond) Call ProcessResponse() TicketNumber = RequestResult End Function Public Function GetTicketURL() 'Response.Write "<hr>AddTicketNote('" & TicketNumber & "')<br>" 'For Debugging Set svcResponse = oSOAP.GetTicketURL(AgentUserName, AgentPassword, TicketNumber) Call ProcessResponse() GetTicketURl = RequestResult End Function Public Function ProcessResponse() For Each Node In svcResponse 'Response.Write Node.tagName & " : " & Node.xml & "<br>" Select Case Node.tagName Case "RequestResult" 'Ticket Number RequestResult = Node.Text Case "Message" Message = Node.Text Case "Result" Result = Node.Text Case "ResultCode" ResultCode = Node.Text Case Else 'Response.write "CreateTicket : Unknown Response Node = " & Node.tagName & "<br>" End Select Next End Function '##################################################################################################### End Class 'Sample Usuage Dim Ticket Set Ticket = New SmarterTrack_svcTicket Ticket.CreateTicket 1,"customer@summit-pro.com", "Missing Items On Order", "Customer reported they did not receive there widget", True Response.Write ( Ticket.GetTicketURL() ) Set Ticket = Nothing %> |
List All Stored Proc Parameters for a Stored Procedure
Here is a simple little script that will list all of a stored procedures parameters. making it easy for you to write your execution code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <table> <tr> <td>Param Name</td> <td>Param Type</td> <td>Param Dir</td> <td>Param Size</td> </tr> <% Set Conn = Server.CreateObject("ADODB.Connection") ' The following line must be changed to reflect your data source info Conn.Open "PROVIDER=SQLOLEDB;Data Source=127.0.0.1;UID=MyUsername;PWD=MyPassword;DATABASE=MyDataBase" set cmd = Server.CreateObject("ADODB.Command") cmd.ActiveConnection = Conn 'Specify the name of the stored procedure you wish to call cmd.CommandText = "MyStoreProcedure" cmd.CommandType = 4 cmd.Execute ' Query the server for what the parameters are cmd.Parameters.Refresh For Each param In cmd.Parameters %> <tr> <TD><%= param.name %></TD><TD> <%= param.type %></TD><TD> <%= param.direction %></TD><TD><%= param.size %></TD> </tr> <% Next Conn.Close %> </TABLE> |