Mirror SVN
I had this set of commands in a file on my desk for ages, so lets share it before everybody moves to git.
For some reasons you may want to replicate a subversion repository. For instance if you have a big SVN with lots of users, you may want a master SVN and read-only slaves. Or maybe your SVN is quite big and doing a full backup each time is too long so you want to do a kind of incremental backup.
Let say you have a subversion repository at http://svn.example.com/repository
and you want to create a mirror of that repository. First you have to create an empty repository on the mirror server:
$ svnadmin create /path/to/repository
Then you have to activate the revision property change hook. To do that you need to create a file in the hooks directory (/path/to/repository/hooks/
). This file is a bit different depending on your platform. On windows you need to create an empty file pre-revprop-change.cmd
. On *nix the file is pre-revprop-change
, must be executable and return 0:
#!/bin/sh
exit 0
Now the mirror need to be initialized with the master content:
$ svnsync init file:///path/to/repository http://svn.example.com/repository
This step can be quite long, your master SVN is copied revision by revision to the mirror. When it's done the only thing you have to do is run the following command from time to time in order to synchronize the mirror with the master:
$ svnsync sync file:///path/to/repository
That's all. But you can also migrate to git and don't bother about backups (mostly 😉).
Comments Add one by sending me an email.