SVN备份还原

转载 2016年02月22日 11:39:39

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

相关文章推荐

SVN备份还原清理BAT

  • 2017年07月21日 10:23
  • 2KB
  • 下载

svn 备份 还原 移植

初级篇:          版本库数据的移植:svnadmin dump、svnadmin load 导出: $svnlook youngest myrepos //查看到目前...

SVN版本库的备份、还原、移植(初级篇、中级篇和高级篇)

初级篇:        版本库数据的移植:svnadmin dump、svnadmin load导出:$svnlook youngest myrepos //查看到目前为止最新的版本号$svnadmi...

SVN版本库的备份、还原、移植(初级篇、中级篇和高级篇)

初级篇:          版本库数据的移植:svnadmin dump、svnadmin load 导出: $svnlook youngest myrepos //查看到目前为止最新的版...

绿色版SVN服务器搭建及备份还原库

1.将绿色版svn-win32-1.5.5解压到任意盘 如:E:\svn-win32-1.5.5 2.配置环境变量(后续操作中会用到) xp->我的电脑->属性->高级->环境变量(WIN7自己...

svn备份和还原的指令

首先要在cmd命令行 中,进入到svn服务器安装的界面。 svn备份一般采用三种方式: 1)svnadmin dump  2)svnadmin hotcopy  3)svnsync. ...

SVN 版本库的备份、还原、移植

初级篇:          版本库数据的移植:svnadmin dump、svnadmin load 导出: $svnlook youngest myrepos //查看到目前为止最新的版本号...

svn的备份与还原怎么用脚本实现svn备份(linux/windows)(转载)

文章来源: http://www.svn8.com/SVNSY/20090605/6174.htmlsvn的备份与还原仓库中版本的备份及还原形式主要有两种:方式一:直接备份仓库整个文件夹(全部版本),...

MySQL数据库(表)的导入导出(备份和还原)

一)在同一个数据库服务器上面进行数据表间的数据导入导出: 1. 如果表tb1和tb2的结构是完全一样的,则使用以下的命令就可以将表tb1中的数据导入到表tb2中: insert into db2.t...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:SVN备份还原
举报原因:
原因补充:

(最多只允许输入30个字)