用记事本新建个.bat文件,把下面的内容copy到文本中保存,修改你自己的环境设置,就好实现这脚本的功能了。
bakcup_svn.bat
SET ZIP_CMD=e:\backup_command\7-zip\7z.ex
SET REPO_PATH=d:\SVNROOT\%1SET REPO_NAME=%1
SET DATE=%2
SET BACKUP_ROOT=E:\backup_root\svn
SET SUBVERSION_ROOT="D:\VisualSVN Server"
SET BACKUP_FILE=%BACKUP_ROOT%\%DATE%\%REPO_NAME%.%DATE%.svn_dump
mkdir %BACKUP_ROOT%\%DATE%
%SUBVERSION_ROOT%\bin\svnadmin.exe dump %REPO_PATH% > %BACKUP_FILE%
%ZIP_CMD% a -tzip %BACKUP_ROOT%\%DATE%\%REPO_NAME%_%DATE%.zip %BACKUP_FILE%
del %BACKUP_FILE% /Q /S
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
dim strRRev
strRRev = GetYoungestFileRev("D:\Work\软件研发中心\SVN备份\youngestRev.txt")
dim strLastRev
'写最新版本
call WriteLastRev()
strLastRev = GetYoungestFileRev("D:\Work\软件研发中心\SVN备份\youngestRev.txt")
'开始增量备份
call DoDailyBackup(clng(strRRev)+1,strLastRev)
msgbox "ok"
function GetYoungestFileRev(vPath)
Dim vYoungestFile
vYoungestFile = vPath
Dim vFso
Set vFso = CreateObject("Scripting.FileSystemObject")
Dim vstream
Set vstream = vFso.OpenTextFile(vYoungestFile, 1, false)
Dim vRRev '上一个版本
While Not vstream.AtEndOfStream
vRRev = vstream.ReadLine
Wend
GetYoungestFileRev = vRRev
vstream.close
set vstream = nothing
set vfso = nothing
end function
function DoDailyBackup(vPRev,vLRev)
Set WshShell = Wscript.CreateObject("Wscript.Shell")
dim vDailyBKCMD
dim vSVNRoot
dim vSVNADMIN
dim svn_repos
dim backup_dir
dim next_backup_file
dim vdate
dim vProjName
vdate = fomat(date,"yyyy-mm-dd")
vSVNRoot = "D:\Program Files\VisualSVN Server\bin"
vSVNADMIN = vSVNRoot & "\svnadmin"
vProjName = "GeoGlobe4_5"
svn_repos = "D:\SourcesafeSVN\Repositories\"& vProjName
backup_dir = "D:\SVNBACKUP\WeekBackup\svn\" &vdate& "\"
next_backup_file = vProjName& "_daily_incremental_backup" & "_" & vdate &
".svn_dump"
vDailyBKCMD = vSVNADMIN & " dump --incremental --revision " & vPRev & " " &
vLRev &" " & svn_repos & " > " &backup_dir & next_backup_file
WshShell.Run vDailyBKCMD
end function
function WriteLastRev()
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run "D:\SVNBACKUP\GetYoungestRev.bat"
end function
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
SET hour=%time:~0,2%
SET hour=%hour: =%
SET DATE=%date:~0,10%_%hour%_%time:~3,2%_%time:~6,2%
bakcup_one_svn.bat 库1 %DATE%
bakcup_one_svn.bat 库2 %DATE%