Perhaps you’d like to create a read-only mirror of your svn repository or clone your repository so that you can make some organizational changes but are afraid to do so in the live production server. Or maybe you just simply want to make a backup of your subversion repository.
If you are a subversion admin you could use the svnadmin hotcopy. Using the OS’s copy command may not make a valid copy.
svnadmin hotcopy /var/svn/repos /var/svn/repos-backup
If you aren’t the subversion admin, svnsync can be used to mirror an entire svn repository including revision history. The process could take some time depending on the number of revisions. Given size and time constraints, initializing the repository over a network connection may not be feasible.
Here’s how to create a remote backup where you don’t have admin access. These instructions assume you have a local subversion installation.
Create the local repository
svnadmin create $local-repo-path
Where $local-repo-path is the file system path to the local repository. This is typically /var/svn/repo
Create the hook script pre-revprop-change and make it executable by all.
For Unix/Linux users create the $local-repo-path/hooks/pre-revprop-change executable file in one or more ways:
echo ‘#!/bin/sh’ > $local-repo-path/hooks/pre-revprop-change && chmod +x $local-repo-path/hooks/pre-revprop-change
Alternatively you could copy template file in the same directory called pre-revprop-change. cp pre-revprop-change.tmpl pre-revprop-change && chmod + x pre-revprop-change
For windows users the file should end in .bat or .exe
exit /B 0
svnsync init file://$local-repo-path $remote-repo-url
Where $local-repo-path is the local file system’s absolute path to the repository and $remote-repo-url is the the URL to the remote repository.
svnsync init file:///var/svn/repo svn://svnhost/repo
svnsync sync file://$local-repo-path
Where $local-repo-path is the local file system’s absolute path to the repository created in the previous step.