Showing posts with label svn. Show all posts
Showing posts with label svn. Show all posts

Wednesday, February 1, 2012

Shell script to backup all of your SVN repositoriesShell script to backup all of your SVN repositories



The script does very basic backup job. Here are the tasks done by this backup script:
  • svnrepos - absolute path of SVN repository root (where all the svn repos are created)
  • bakdest - absolute path of directory where you would like to save all SVN dumps
  • baktousb - absolute path of additional folder path to copy SVN dump (could be connected USB drive)
Read the original article

Tuesday, April 27, 2010

Windows Subversion Maintenance Scripts

create_repo.bat

@echo off

REM Check command line args to make sure a customer and project name were passed
IF (%1)==() GOTO CMDLINE
IF (%2)==() GOTO CMDLINE

REM If svnadmin is not in your path, uncomment the following
REM PATH=%PATH%;"D:\Program Files\Subversion\bin"

REM Set up variables with the directories
SET CUSTOMER=%1
SET PROJECT=%2
SET CUR_DIR=%~dp0
SET CUR_DIR=%CUR_DIR:\=/%
SET SVN_DIR=%CUR_DIR%/repos/%CUSTOMER%
SET PROJ_DIR=file:///%SVN_DIR%/%PROJECT%

echo Creating directory in %SVN_DIR%

svnadmin create "%SVN_DIR%"
svn -m "Create default structure." mkdir %PROJ_DIR% %PROJ_DIR%/trunk %PROJ_DIR%/tags %PROJ_DIR%/branches
GOTO END

:CMDLINE
echo Usage: %0 ^ ^

:END
echo Done



dump_all.bat

@echo off

SET DUMP_DIR=dumps
SET REPOS_DIR=repos

IF NOT EXIST %DUMP_DIR% (
echo Creating directory %DUMP_DIR%
md %DUMP_DIR%
)

echo Dumping...

FOR /f %%i IN ('dir /B /A:D %REPOS_DIR%\*') DO (
echo Dumping %REPOS_DIR%\%%i to %DUMP_DIR%\%%i.dump
svnadmin dump %REPOS_DIR%\%%i > %DUMP_DIR%\%%i.dump
)


restore_all.bat

@echo off

SET DUMP_DIR=dumps
SET REPOS_DIR=repos

echo Restoring....

REM %%~ni becomes the dump name without .dump

FOR /f %%i IN ('dir /B %DUMP_DIR%\*.dump') DO (
echo Restoring %DUMP_DIR%\%%i to %REPOS_DIR%\%%~ni
svnadmin create %REPOS_DIR%\%%~ni
svnadmin load %REPOS_DIR%\%%~ni < %DUMP_DIR%\%%i
)