关闭

SVN备份还原

172人阅读 评论(0) 收藏 举报
分类:

SVN备份:

----------------------准备--------------------------------------

SVN工作目录:D:\Repositories

备份文件目录:W:\MySvnBackup\MyBackupFile

------------------------创建bat文件---------------------------

@echo off

rem --------set svn directory----------
set svnpath=D:\Repositories


rem --------set backup directory----------
set SvnIncrementBackupPath=W:\MySvnbackup


rem --------log file path----------
set log_path=W:\BackupLog
set lastRevision_path=W:\LastRevision


rem --------set backup project----------
set backproject=MyProject1
set backproject1=MyProject2
set backproject2=MyProject3


if not exist %SvnIncrementBackupPath% (mkdir %SvnIncrementBackupPath%)
 
D:
cd %svnpath%
dir /b /ad > dirs


if exist temp_directory (
   del /q temp_directory
  )


for /f %%I in ( dirs ) do if exist "%%I\conf\svnserve.conf"  echo %%I >> temp_directory
 
for /f %%i in ( temp_directory ) do (


 if %%i==%backproject% (
   set project=%%i
   call :Dump_Entrence
   )
if %%i==%backproject1% (
   set project=%%i
   call :Dump_Entrence
   )
if %%i==%backproject2% (
   set project=%%i
   call :Dump_Entrence
   )
 )


del /q dirs
del /q temp_directory
 
:Dump_Entrence
 
if not exist %SvnIncrementBackupPath%\%project% mkdir %SvnIncrementBackupPath%\%project%
if not exist %log_path% (mkdir %log_path%)
if not exist %lastRevision_path% (mkdir %lastRevision_path%)
 
set lower=0
set upper=0


svnlook youngest %svnpath%\%project%> %log_path%\A.TMP
 
for /f %%D in (%log_path%\A.TMP) do set upper=%%D


if %upper%==0 goto :N_EXIT 


if not exist %lastRevision_path%\%project%_last_revision.txt goto :BACKUP


for /f %%C in (%lastRevision_path%\%project%_last_revision.txt) do set lower=%%C


set /a lower=%lower%+1


if %lower% gtr %upper% goto :N_EXIT


:BACKUP
echo start backup %project%


set filename=%project%_%lower%_%upper%


echo %date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%:start backup %project%, revision:%lower% to %upper% >>%log_path%\%project%.log
svnadmin dump %svnpath%\%project% -r %lower%:head --incremental >%SvnIncrementBackupPath%\%project%\%filename%.dmp
echo %date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%:end backup %project% >>%log_path%\%project%.log
echo.>>%log_path%\%project%.log


echo %project% backup successful


:COMPLETE
echo %upper% > %lastRevision_path%\%project%_last_revision.txt


:N_EXIT
del %log_path%\A.TMP


exit /B


ECHO ON

----------------------创建结束---------------------------------


SVN还原:

---------------------准备--------------------------

SVN工作目录:D:\Repositories

备份文件目录:W:\MySvnBackup\MyBackupFile

待还原目录:RecoverBackupDir

-------------------创建bat文件---------------------

@echo off
rem --------set svn directory----------
set svnPath=D:\Repositories


rem --------set recover directory----------
set svnRecoverPath=W:\MySvnBackup\MyBackupFile


rem --------set recover project name----------
set svnRecoverName=RecoverBackupDir


cd %svnPath%


rem --------create a new svn----------
svnadmin create %svnRecoverName%


rem --------list all dmp fileName to temp file dirsTest----------
dir /b %svnRecoverPath%\*.dmp > %svnPath%\dirsTest


rem --------load the dmp file to recover project ----------
for /f %%i in (dirsTest) do svnadmin load %svnRecoverName% < %svnRecoverPath%\%%i


rem --------delete the temp file dirsTest----------
del /q dirTest


@echo on

---------------创建结束------------------------------------------------

SVN工作目录:D:\Repositories

备份文件目录:W:\MySvnBackup\MyBackupFile

待还原目录:RecoverBackupDir

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:8238次
    • 积分:202
    • 等级:
    • 排名:千里之外
    • 原创:11篇
    • 转载:9篇
    • 译文:0篇
    • 评论:0条
    文章分类