================== 备份 1/2 ==================
svnbackup.bat
@echo off
@rem Subversion Server 的安装目录
set SVN_HOME=D:\Program Files\VisualSVN Server
@rem 所有版本库的父目录
set SVN_ROOT=E:\svn
@rem 备份的目录
set BACKUP_SVN_ROOT=F:\svnbackups
@rem 备份日期目录(例如:20190429)
set THISDATE=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%
set BACKUP_DIRECTORY=%BACKUP_SVN_ROOT%\%THISDATE%
if exist %BACKUP_DIRECTORY% goto echo_dir_exist
@rem 建立备份目录
mkdir %BACKUP_DIRECTORY%
@rem 验证目录是否为版本库,如果是则取出名称备份,并调用svnhotcopy.bat进行备份
for /r %SVN_ROOT% %%I in (.) do @if exist "%%I\conf\svnserve.conf" %SVN_ROOT%\svnhotcopy.bat %%~fI %%~nI
goto end
:echo_dir_exist
echo 备份目录%BACKUP_DIRECTORY%已经存在,请清空后重新备份。
goto end
:end
pause
================== 备份 2/2 ==================
svnhotcopy.bat
@rem 此bat需要放在版本库SVN_ROOT目录下
@echo === 正在备份版本库%1 ===
@mkdir %BACKUP_DIRECTORY%\%2
@"%SVN_HOME%\bin\svnadmin" hotcopy "%1" "%BACKUP_DIRECTORY%\%2"
@echo 版本库%1成功备份到了%BACKUP_DIRECTORY%\%2
================== 还原 ==================
copy <backup_directory> to <svn_directory>