svn伺服器ip位址10.200.144.250 svn備份伺服器ip位址10.200.144.251
1. 在備份伺服器上建立svn倉庫
svnadmin create d:\ur_backup\ur
2. 在svn備份伺服器hooks目錄下新建檔案pre-revprop-change.bat,開啟pre-revprop-change.bat寫入
exit 0;
儲存。3. 在svn伺服器hooks目錄下新建檔案post-commit.bat,開啟post-commit.bat寫入
svnsync sync --non-interactive svn: --username admin --password admin
4.同步初期化,在備份伺服器執行下面的命令
svnsync init svn: svn:
會要求輸入使用者名稱密碼,填入備份svn的使用者名稱和密碼。
5.同步版本庫,在備份伺服器執行下面的命令
svnsync sync svn: --username admin --password admin
注意事項:不能在備份伺服器進行提交操作。
打包備份
dumpall.bat備份,打包用到了window自帶的zip命令,找不到zip命令的話,到
@echo off
set dumpto_dir="."
if not "%1" == "" (
echo back up all to %1
set dumpto_dir=%1 )
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.
if exist %dumpto_dir%\repos_%var_date%.zip (
echo delete existing compressed dump file
del %dumpto_dir%\repos_%var_date%.zip )
echo compressing dump files...
zip -j %dumpto_dir%\repos_%var_date%.zip %dumpto_dir%\*.bin
echo delete dump files...
for /f %%i in (dump_files) do (
del /q %dumpto_dir%\%%i )
del /q dirs
del /q dump_files
set dumpto_dir=
echo successed.
goto :eof
::==== functions ====
:dump_repos
set dump_file=%repos_name%.bin
echo dumping repository ^"%repos_name%^" ...
svnadmin dump ^"%repos_name%^" -q > %dumpto_dir%/%dump_file%
if %errorlevel%==0 (
echo %dump_file% >> dump_files
) else (
del /q %dump_file%
echo dump ^"%repos_name%^" failed. )
set dump_file=
echo.
loadall.bat,解壓zip檔案後才能還原
set var_is_empty_dir=true
set load_dir=".";
if not "%1"=="" (
set load_dir=%1 )
echo %load_dir%
set var_is_empty_dir=
dir /b /a-d %load_dir%\*.bin > dump_files
if "%errorlevel%"=="0" (
echo finded dump file.
) else (
echo error : can not find dump file.
del dump_files
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 %repos_name%
echo loading repository ^"%repos_name%^" ...
svnadmin create %repos_name%
svnadmin load -q %cd%\%repos_name% < %load_dir%/%repos_file%
if %errorlevel%==0 (
echo %dump_file% >> dump_files
) else (
rmdir /q %repos_name%
echo load ^"%repos_name%^" failed. )
set repos_name=
echo.
SVN同步備份
首先建立乙個空的repository,svnadmin create svn。起初想嘗試在已有的repository中單獨建立乙個目錄來做備份,但是反覆嘗試無數次,失敗告終。因為只能在root下做同步,我查便了svnserve命令也沒找到怎麼以子目錄為root啟動svn,所以,只有新建了。新建後首先...
svn備份指令碼
svn備份一般採用三種方式 1 svnadmin dump 2 svnadmin hotcopy 3 svnsync.注意,svn備份不宜採用普通的檔案拷貝方式 除非你備份的時候將庫暫停 如copy命令 rsync命令。筆者曾經用 rsync命令來做增量和全量備份,在季度備份檢查審計中,發現備份出來...
svn備份還原
備份svn庫。將svn庫備份匯出到c svnbak,生成dump檔案。在cmd命令列裡輸入 svnadmin dump c svnroot repos1 c svnbak repos1.dump 匯入備份庫到新的svn庫下。匯入備份庫到新的svn庫下時,一定要新建庫!1,在svnroot目錄下新建空...