Best Practices for Backup and Disaster Recovery of VisualSVN Repositories on Windows


16 views

When backing up VisualSVN repositories by copying the entire repositories directory, you're essentially performing a cold backup of the Subversion filesystem. This method captures the complete state including all revisions, hooks, and repository metadata stored in the FSFS format (default since SVN 1.9).

To ensure your backup is restorable, perform these validation steps:

# Verify repository integrity using svnadmin
svnadmin verify C:\Path\To\Backup\repository_name

# Check repository UUID consistency (critical for replication)
svnlook uuid C:\Path\To\Backup\repository_name

In disaster scenarios, follow this restoration workflow:

  1. Stop VisualSVN Server service
  2. Rename/Rmove corrupted repository folder
  3. Copy backup folder to original location
  4. Set proper permissions (inherited from parent folder)
  5. Restart VisualSVN Server service

Consider implementing these robust backup strategies:

:: Windows batch script for hot backups
@echo off
set SVN_BACKUP=D:\svn_backups\%date:~-4,4%%date:~-10,2%%date:~-7,2%
mkdir %SVN_BACKUP%
for /D %%G in ("C:\Repositories\*") do (
   svnadmin hotcopy "%%G" "%SVN_BACKUP%\%%~nG"
   svnadmin verify "%SVN_BACKUP%\%%~nG"
)

This PowerShell script performs automated backup verification:

# PowerShell backup validation
$backupPath = "D:\svn_backups\latest"
$repos = Get-ChildItem $backupPath -Directory

foreach ($repo in $repos) {
    $output = & "svnadmin" "verify" $repo.FullName 2>&1
    if ($LASTEXITCODE -ne 0) {
        Write-Output "Verification failed for $($repo.Name)"
        # Add alerting logic here
    }
}

When restoring, watch for these issues:

  • Permission conflicts (especially when moving to new servers)
  • UUID mismatch (use svnadmin setuuid if needed)
  • Hook script execution permissions
  • Repository DB format compatibility (when migrating between SVN versions)

For large repositories, consider incremental backups using dump files:

# Create incremental dump (Windows CMD)
svnadmin dump C:\Repositories\project_repo --incremental -r 1000:HEAD > D:\backups\project_repo_incr_1000-HEAD.dmp

# Restore incremental dump
svnadmin load C:\RestoredRepos\project_repo < D:\backups\project_repo_incr_1000-HEAD.dmp

When backing up VisualSVN repositories on Windows, it's crucial to understand the underlying structure. The repositories are stored in the Repositories directory (typically located at C:\Repositories by default), which contains:

  • Each repository as a separate directory
  • DB/FSFS storage format files
  • Configuration files
  • Hook scripts

The method you're currently using - backing up the entire repositories directory - is actually one of the most reliable approaches for VisualSVN. The FSFS storage format (default since SVN 1.9) is specifically designed to allow:

# Example PowerShell command to verify repository integrity
svnadmin verify C:\Repositories\your_repo

Here's the proven restoration process we've used in production environments:

  1. Stop the VisualSVN Server service
  2. Delete the corrupted repository folder (if exists)
  3. Restore the repository folder from backup
  4. Run repository verification:
# Batch script example for automated verification
@echo off
set REPO_PATH=C:\RestoredRepos\project_repo
"C:\Program Files\VisualSVN Server\bin\svnadmin.exe" verify %REPO_PATH%
if %errorlevel% neq 0 (
    echo Repository verification failed
    exit /b 1
) else (
    echo Repository verified successfully
)

For those wanting more advanced options, consider these alternatives:

Method Command Pros
svnadmin hotcopy svnadmin hotcopy C:\Repositories\repo C:\Backup\repo Safe for live repositories
svnadmin dump svnadmin dump C:\Repositories\repo > repo.dump Portable across versions

Here's a production-grade PowerShell script we use for scheduled backups:

# VisualSVN Backup Script
$ReposPath = "C:\Repositories"
$BackupRoot = "D:\SVN_Backups"
$DateStamp = Get-Date -Format "yyyyMMdd"

Get-ChildItem $ReposPath | ForEach-Object {
    $RepoName = $_.Name
    $BackupPath = Join-Path $BackupRoot "$RepoName-$DateStamp"
    
    # Create hotcopy
    & "C:\Program Files\VisualSVN Server\bin\svnadmin.exe" hotcopy $_.FullName $BackupPath
    
    # Verify the backup
    & "C:\Program Files\VisualSVN Server\bin\svnadmin.exe" verify $BackupPath
    
    # Compress backup
    Compress-Archive -Path $BackupPath -DestinationPath "$BackupPath.zip"
    Remove-Item $BackupPath -Recurse -Force
}

After any restoration, always perform these checks:

  • Verify repository UUID matches original (check db/uuid file)
  • Test checkout operation
  • Validate revision history through log
  • Test commit operations (if possible)