1.建立bat文件 simpleBackup.bat,文件内容如下
@echo 正在备份版本库%1......
@%SVN_HOME%binsvnadmin hotcopy %1 %BACKUP_DIRECTORY%/%2
@echo 版本库%1成功备份到了%2!
2.建立bat文件svn备份.bat,文件内容如下
@Echo Off
rem Subversion的安装目录
set SVN_HOME="C:Program FilesVisualSVN Server"
rem 所有版本库的父目录
set SVN_ROOT=E:/SvnServer
rem 备份的目录
set BACKUP_SVN_ROOT=E:SVNBackUp
set BACKUP_DIRECTORY=%BACKUP_SVN_ROOT%/%date:~0,10%
rem 如果已经存在当天的备份文件夹,就跳到下面的提示信息
if exist %BACKUP_DIRECTORY% goto checkBack
echo 建立备份目录%BACKUP_DIRECTORY%>>%SVN_ROOT%/backup.log
mkdir "%BACKUP_DIRECTORY%"
rem 验证目录是否为版本库,如果是则取出名称备份
for /r %SVN_ROOT% %%I in (.) do @if exist "%%Iconfsvnserve.conf" call %SVN_ROOT%simpleBackup.bat "%%~fI" %%~nI
echo 开始压缩版本库,请不要中止....
%SVN_ROOT%7zG.exe a -tzip %BACKUP_SVN_ROOT%\%date:~0,4%%date:~5,2%%date:~8,2%.zip %BACKUP_DIRECTORY%* -r >nul
echo 版本库压缩完成!
goto end
:checkBack
echo 备份目录%BACKUP_DIRECTORY%已经存在,请清空。
goto end
:end
echo open 10.11.109.246>abc.txt
echo user svnback svnback>>abc.txt
Echo binary>>abc.txt
Echo Cd ./homes/svnback/SVN-back/>>abc.txt
Echo put "%BACKUP_SVN_ROOT%\%date:~0,4%%date:~5,2%%date:~8,2%.zip">>abc.txt
echo bye>>abc.txt
ftp -n -s:abc.txt
del abc.txt
rem 清除临时创建备份目录
rd /s /q "%BACKUP_SVN_ROOT%"
rem Pause
3.添加时间任务,简单不赘述