Subversion (SVN) is a version control system initiated in 2000 by CollabNet Inc. It is used to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly-compatible successor to the widely used Concurrent Versions System (CVS). Subversion is well-known in the open source community and is used on many open source projects.
Subversion was started in 2000 as an effort to write a free version control system which operated much like CVS but with fixed bugs and misfeatures in CVS. By 2001, Subversion was sufficiently developed to be capable of hosting its own source code. More information, including this above paragraph, is here.
Why Change Repository Location?
It’s a really good question – especially since it adheres to the time tested & trusted quote If it ain’t broken, don’t fix it. My repository was located at ${HOME}/svn_repo
since inception and recently, the linux box that housed this repository was upgraded. And as a result of this upgradation, the value of ${HOME}
is no longer the same. As such, it became necessary to change the location of this repository – to a place that has more storage space.
Backup The Repository
After committing all recent changes, I did backup the repository using a script I wrote over a year ago. Suppose that this repository dump is called svnrepo.dump
and that it’s stored in /tnp
.
Create The New Repository & Import The Dump/Backup
1 2 3 | cd /scratch/$USER/ svnadmin --fs-type fsfs create /scratch/$USER/svn_repo svnadmin load /scratch/$USER/svn_repo < /tmp/svnrepo.dump |
It’s more than likely – especially if you backed up your repository using my script – that you are presented with the following error message:
Dump stream contains a malformed header (with no ‘:’) at ‘* Dumped revision 0.’
Prime reason for this error message is that my script dumped both stdout and stderr to the dump file. And the svnadmin load
doesn’t like it. The fix is a one-liner:
1 | grep --binary-files=text -v '^* Dumped revision' /tmp/svnrepo.dump > /tmp/svnrepo_1.dump |
Once that’s done [time to clean up depends on the size of the dump file as well as system resources], run:
1 | svnadmin load /scratch/$USER/svn_repo < /tmp/svnrepo_1.dump |
Time to load the dump file contents into the repository depends on the size of the dump file as well as system resources.
Inform The Clients
Once the dump/backup was successfully loaded into the repository, the client [machines that check out a working copy and check in edits] needs to know about this change in repository location. My working copy is in /scratch/$USER/svn_work
. So, all I did was
1 2 3 4 5 | cd /scratch/$USER/svn_work cd PROJECT svn switch --relocate svn+ssh://hostname/${HOME}/svn_repo \ svn+ssh://hostname/scratch/$USER/svn_repo svn up |
While the above process of informing the clients is relatively easier when there are few projects in a repository, it can get pretty tedious and time consuming when the number of projects is significantly higher. To that end, you may use the script I use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #! /bin/bash # svn_switchrepo.sh # BASH script to inform the subversion client about the change in repository location. # Automagically generates the list of projects # # USAGE: svn_switchrepo.sh # # First written: Gowtham; Wed, 17 Nov 2010 12:40:04 -0500 # Last modified: Gowtham; Wed, 17 Nov 2010 12:40:04 -0500 # Automagical generation of the project list export MYPROJECTS=`svn list svn+ssh://hostname/scratch/$USER/svn_repo \ | sort | awk -F '/' '{print $1}'` echo for x in $MYPROJECTS do clear cd /scratch/$USER/svn_work/ echo " Switching repository for project ${x}" cd ${x} # svn switch --relocate OLD_REPO_URL/PATH NEW_REPO_URL/PATH svn switch --relocate svn+ssh://hostname/${HOME}/svn_repo \ svn+ssh://hostname/scratch/$USER/svn_repo svn up echo " Done" done echo |
One Reply to “Subversion – Changing Repository Location”