Skip to content

Instantly share code, notes, and snippets.

@michaeljbailey
Last active August 29, 2015 14:17
Show Gist options
  • Save michaeljbailey/e52c92bd83163b879ab0 to your computer and use it in GitHub Desktop.
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.
# 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