Last active
August 29, 2015 14:17
-
-
Save michaeljbailey/e52c92bd83163b879ab0 to your computer and use it in GitHub Desktop.
Some PowerShell wrappers for commonly used svnadmin commands. The functions exported make several assumptions and are *very* simple. Think of these as more of starter scripts to modify or build up on.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: The below does not yet handle paths with spaces because I was being lazy. | |
function Import-SvnRepository($SvnAdminPath, $RepositoryPath, $InputPath) | |
{ | |
& cmd /c "`"$SvnAdminPath`" load $RepositoryPath --memory-cache-size 256 < $InputPath" | |
} | |
function Export-SvnRepository($SvnAdminPath, $RepositoryPath, $OutputPath, [Switch]$UseDelta) | |
{ | |
if ($UseDelta) | |
{ | |
& cmd /c "`"$SvnAdminPath`" dump $RepositoryPath --memory-cache-size 256 --deltas > $OutputPath" | |
} | |
else | |
{ | |
& cmd /c "`"$SvnAdminPath`" dump $RepositoryPath --memory-cache-size 256 > $OutputPath" | |
} | |
} | |
function Copy-SvnRepository($SvnAdminPath, $RepositoryPath, $OutputPath) | |
{ | |
& cmd /c "`"$SvnAdminPath`" hotcopy $RepositoryPath $OutputPath" | |
} | |
function Optimize-SvnRepository($SvnAdminPath, $RepositoryPath) | |
{ | |
Get-ChildItem -Path $RepositoryPath -Recurse | Measure-Object -Sum Length | |
& cmd /c "`"$SvnAdminPath`" pack $RepositoryPath" | |
Get-ChildItem -Path $RepositoryPath -Recurse | Measure-Object -Sum Length | |
} | |
function Get-SvnRepositorySize($RepositoryRoot) | |
{ | |
Get-ChildItem -Path $RepositoryRoot | ? PsIsContainer ` | |
| % { Get-ChildItem -Path $_.FullName -Recurse | Measure-Object -Sum Length | Add-Member -MemberType NoteProperty -Name "Name" -Value $_.Name -PassThru } ` | |
| Sort -Property Count -Descending | Format-Table -AutoSize | |
} | |
function Test-SvnRepository($SvnAdminPath, $RepositoryPath) | |
{ | |
& cmd /c "`"$SvnAdminPath`" verify $RepositoryPath --memory-cache-size 256" | |
return $LastExitCode -eq 0 | |
} | |
function Update-SvnRepository($SvnAdminPath, $RepositoryPath) | |
{ | |
& cmd /c "`"$SvnAdminPath`" upgrade $RepositoryPath" | |
} | |
function Repair-SvnRepository($SvnAdminPath, $RepositoryPath) | |
{ | |
& cmd /c "`"$SvnAdminPath`" recover $RepositoryPath --wait" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment