2012-03-19

How to sync svn repositories

Here's a simple receipe on how to sync a svn repository using svnsync.

First, create two variables. One to specify where is the source repository, the other to specify where is the target directory

TARGET_SVN=/tmp/destsvn
SOURCE_SVN=http://mysvnhost/subversion

Prepare the target directory


mkdir $TARGET_SVN
cd $TARGET_SVN
#Create the bare svn repository
svnadmin create .
#create a dummy pre-revprop-change hook
echo '#!/bin/bash' > hooks/pre-revprop-change
chmod +x hooks/pre-revprop-change
 
#prepare the target for the sync
svnsync initialize file://$(readlink -f $TARGET_SVN) $SOURCE_SVN

readlink makes sure that the path is in a canonized form.


Synchronize!


svnsync sync file://$(readlink -f $TARGET_SVN) 

That's it!

You can repeat this part periodically to sync with the remote repository.

1 comment: