SVN簡単なバックアップとリストア

23442 ワード

SVN倉庫をバックアップするのは面倒なことで、Coderは通常面倒な人を恐れているので、Zealicは面倒を減らすために少し面倒な時間を費やして、2つの面倒なスクリプトを書いて、この面倒な問題を解決しました.

  1.バックアップスクリプトDumpAll.bat


Copy Code

  
    
@ECHO OFF :: ==================== :: Author : Zealic :: Version : 1.00 :: FileName : DumpAll.bat :: Summary : Dump Svn , SVN , :: 7za.exe , :: http://downloads.sourceforge.net/sevenzip/7za457.zip :: Update : 2008-11-26 :: ==================== SET VAR_DATE = % DATE :~ 0 , 4 %% DATE :~ 5 , 2 %% DATE :~ 8 , 2 % dir / B / AD > DIRS IF EXIST DUMP_FILES ( DEL / Q DUMP_FILES ) FOR / F %%i IN ( DIRS ) DO ( SET REPOS_NAME = %%i CALL :DUMP_REPOS ) SET REPOS_NAME = ECHO . ECHO Compressing dump files ... 7za a Repos_%VAR_DATE% . 7z * . bin ECHO Delete dump files ... FOR / F %%i IN ( DUMP_FILES ) DO ( DEL / Q %%i ) DEL / Q DIRS DEL / Q DUMP_FILES ECHO Successed . GOTO :EOF :: ==== Functions ==== :DUMP_REPOS SET DUMP_FILE = %REPOS_NAME% . bin ECHO Dumping repository ^ " %REPOS_NAME%^ " ... svnadmin dump ^ " %REPOS_NAME%^ " -q > %DUMP_FILE% IF % errorlevel % == 0 ( ECHO %DUMP_FILE% >> DUMP_FILES ) ELSE ( DEL / Q %DUMP_FILE% ECHO Dump ^ " %REPOS_NAME%^ " failed . ) SET DUMP_FILE = ECHO .

 

2.スクリプトを復元bat


Copy Code

  
    
@ECHO OFF :: ==================== :: Author : Zealic :: Version : 1.00 :: FileName : LoadAll.bat :: Summary : Load Svn , , :: *.bin , Load Dump 。 :: Update : 2008-11-26 :: ==================== SET VAR_IS_EMPTY_DIR = TRUE dir / B / AD > DIRS FOR / F %%i IN ( DIRS ) DO ( SET VAR_IS_EMPTY_DIR = FALSE ) DEL / Q DUMP_FILES IF " %VAR_IS_EMPTY_DIR% " == " FALSE " ( ECHO Error : Current directory is not empty . GOTO :EOF ) SET VAR_IS_EMPTY_DIR = dir / B / A-D * . bin > DUMP_FILES IF " %errorlevel% " == " 0 " ( ECHO Finded dump file . ) ELSE ( ECHO Error : Can not find dump file . GOTO :EOF ) FOR / F %%i IN ( DUMP_FILES ) DO ( SET REPOS_FILE = %%i CALL :LOAD_REPOS ) SET REPOS_FILE = DEL / Q DUMP_FILES ECHO Successed . GOTO :EOF :: ==== Functions ==== :LOAD_REPOS SET REPOS_NAME = %REPOS_FILE:~ 0 , - 4 % mkdir %REPOS_NAME% ECHO Loading repository ^ " %REPOS_NAME%^ " ... svnadmin create %REPOS_NAME% svnadmin load -q % cd % \ %REPOS_NAME% < %REPOS_FILE% IF % errorlevel % == 0 ( ECHO %DUMP_FILE% >> DUMP_FILES ) ELSE ( RMDIR / Q %REPOS_NAME% ECHO Load ^ " %REPOS_NAME%^ " failed . ) SET REPOS_NAME = ECHO .

面倒が解決したので、娯楽に行くことができます.
 
2008-11-26 Zealic