Saturday, September 20, 2008

Subversion SVN Backup - HotCopy Not a folder copy

Subversion hotcopy is tricky, because you have to empty the contents of the destination folder before you run the svnadmin hotcopy command.

To do this I create a console vb.net app and run it before the svnadmin command runs.App is really simple and has the following code in it.


Try
''share of the destination folder
Dim folder As String = "\\svnbackupserver\svnreposbackup"
Dim rootFiles() As String = System.IO.Directory.GetFiles(folder)
For Each file In rootFiles
System.IO.File.SetAttributes(file, FileAttributes.Normal)
System.IO.File.Delete(file)
Next
Dim dr() As String = System.IO.Directory.GetDirectories(folder)
For Each item In dr
Dim str() As String = System.IO.Directory.GetFiles(item)
For Each item1 In str
System.IO.File.SetAttributes(item1, FileAttributes.Normal)
Next
System.IO.Directory.Delete(item, True)
Next
Catch ex As Exception
Print(ex.Message)
End Try
End Sub
'''''''''''''''''''''

C:\Batch\SVNBackup.exe svnadmin hotcopy \\svnserver\svnrepo \\svnserverbackup\SvnReposBackup

No comments:

Post a Comment