For those of you still on SVN (and so I don’t forget) here’s a few SVN tips for when moving repositories
Updating your local copy If your repository is moved
If the repo moves, to a new server or changes protocal (ssh -> https) etc. Then there’s a simple command for seamlessly updating your local checked out copy
svn switch --relocate
To figure out what should be look in the .svn/entries file in the top dir of your local copy.
You’ll see something like (for svn+ssh)
svn+ssh://username@svnserver.com/var/lib/svn/project_name/trunk
svn+ssh://username@svnserver.com/var/lib/svn/project_name
so if you are moving to new-svnserver.com then you’d use:
svn switch --relocate svn+ssh://username@svnserver.com/var/lib/svn/project_name/trunk svn+ssh://username@new-svnserver.com/var/lib/svn/project_name/trunk
or perhaps you’re moving to a hostedservice.com and accessing over https:
svn switch --relocate svn+ssh://username@svnserver.com/var/lib/svn/project_name/trunk https://hostedservice.com/myaccount/project_name/trunk
If you happen to have a number of projects in the same dir all needing the same migration, here’s a quick shell script to loop through them all:
#some config
DATA_PATH=/path/to/projects
OLD_SERVER=svn+ssh://username@oldeserver/var/lib/svn/
NEW_SERVER=https://hostedrepo.com/accoutname/
cd $DATA_PATH
for i in *
do
if [ -f $DATA_PATH/$i/.svn/entries ]
then cd $DATA_PATH/$i && line=$(grep -m1 $OLD_SERVER .svn/entries);
new_line=$(echo "$line" | sed "s|$OLD_SERVER|$NEW_SERVER|g")
svn switch --relocate $line $new_line;
fi
cd $DATA_PATH
done
Migrating a repository to a new server
It’s pretty simple to migrate repositories with the command
svn dump
1. On the old server, dump all the individual projects in /var/lib/svn (or wherever your repository is located)
cd /var/lib/svn
for i in *;do echo $i; svnadmin dump $i > /path/to/dump/$i.dump;done
scp /path/to/dump/*.dump newserver:/tmp/
2. assuming you have already installed svn on the new server with a svn user account (assumed to be svn below), load the dumped data:
#load the dumps we just copied accross
cd /tmp/
for i in *.dump;do REPO=$(echo $i | sed s/.dump//g); svnadmin create /var/lib/svn/$REPO; svnadmin load /var/lib/svn/$REPO < $i;done
#now set permissions
cd /var/lib/svn/
for i in *;do echo $i; chown -R svn:svn $i; chmod -R g+w $i/db;done
3. The you’ll probably want to follow the tip above about updating clients with the new server url
references
https://wiki.archlinux.org/index.php/Subversion_backup_and_restore
http://svnbook.red-bean.com/en/1.1/ch05s03.html#svn-ch-5-sect-3.5
José says
Thanks a lot for posting this info here, it gave me very nice ideas