@echo off rem Copyright (C) 2009-2011 by Jelle Geerts rem rem Permission is hereby granted, free of charge, to any person obtaining a copy rem of this software and associated documentation files (the "Software"), to deal rem in the Software without restriction, including without limitation the rights rem to use, copy, modify, merge, publish, distribute, sublicense, and/or sell rem copies of the Software, and to permit persons to whom the Software is rem furnished to do so, subject to the following conditions: rem rem The above copyright notice and this permission notice shall be included in rem all copies or substantial portions of the Software. rem rem THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR rem IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, rem FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE rem AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER rem LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, rem OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN rem THE SOFTWARE. setlocal set rval=1 set lockfile=%tmp%\svnmirror.lock set svn_username_cmdarg= if %1x == x goto :usage if %2x == x goto :usage if %3x == x goto :f set svn_username_cmdarg=--username %3 :f set repo_name=%1 set archive_ext=bz2 rem Check if the output file already exists. if exist "%tmp%\%repo_name%.tar.%archive_ext%" goto :e_output rem Dependency checks. sed --version >nul 2>&1 if not %errorlevel%x == 0x ( call :e_dep sed goto :exit ) tar --version >nul 2>&1 if not %errorlevel%x == 0x ( call :e_dep tar goto :exit ) bzip2 --help >nul 2>&1 if not %errorlevel%x == 0x ( call :e_dep bzip2 goto :exit ) rem Lock to one instance of this script. if exist "%lockfile%" goto :e_instance echo.>"%lockfile%" rem Create temporary local repository directory. set mkdir=%tmp%\%repo_name% mkdir "%mkdir%" >nul 2>&1 if not %errorlevel%x == 0x goto :e_mkdir set orig_dir=%cd% cd /d "%mkdir%" svnadmin create . echo.>hooks\pre-revprop-change.bat rem Convert backslashes to slashes in the path to the repository. set tmpfile=%tmp%\svnmirror.sed echo %cd%| sed "s:\\:/:g" >"%tmpfile%" set /p dir=<"%tmpfile%" del "%tmpfile%" rem Fetch the remote repository. set local_url=file:///%dir% svnsync init "%local_url%" %2 %svn_username_cmdarg% if not %errorlevel%x == 0x goto :e_fetch svnsync sync "%local_url%" %svn_username_cmdarg% if not %errorlevel%x == 0x goto :e_fetch rem Create a compressed tarball of the repository. cd /d "%tmp%" tar cf "%repo_name%.tar" "%repo_name%" bzip2 -9 "%repo_name%.tar" rem Move the compressed tarball to the directory the user was originally in rem when invoking this script. mv "%repo_name%.tar.%archive_ext%" "%orig_dir%" set rval=0 goto :exit :usage echo Usage: svnmirror REPO_NAME SVN_REPO_URL [SVN_USERNAME] echo Options: echo REPO_NAME Just a short name for the repository. echo Used to name the output tarball after. echo SVN_REPO_URL The URL of the remote repository to mirror. echo SVN_USERNAME Username to authenticate with. goto :exit :error set /p null=*** ERROR: