From WhyNotWiki
Jump to: navigation, search


$ svnadmin create
$ svnsync init file://$PWD/
$ svnsync sync file://$PWD/

The example performs the following tasks:

  • Creates a new local repository named
  • Initializes the (local) repository to be a mirror of (remote)
  • Synchronizes the repository with its initialized source

Note that this is point-in-time synchronization. To keep an up-to-date mirror you'll have to run svnsync sync on a regular basis (e.g. by cron job or post-commit hook).

Q: So what can I do with this thing anyway? A: Well, anything that's read-only. As long as you don't commit changes to the destination repository you're all set. This means destination repositories are good for providing offsite mirrors, read-only mirrors, etc.

What does svnsync init do?

$ svnsync init ${TOREPO} ${FROMREPO}

This will prompt you for the username, password, and also sets several revision properties on the $TOREPO, for revision zero. It doesn't actually copy any of the data yet. To list the properties that it created, run:

$ svn proplist --revprop -r 0 ${TOREPO}


How to set it up so your destination repo is updated automatically when your source repo is updated

I personally set [up] a 'live' sync, but it is also possible to use a crontab or other scheduling method to invoke sync whenever you want. To set up a live sync, on the FROMREPO server, I appended this to my hooks/post-commit file:

svnsync --non-interactive sync svn:// &

You will want to make sure that the user-running subversion (and the hook script) has a cached copy of the authentication info for the destination repository.

Unfortunately, the post-commit hook won't catch everything, so we also need to added this to the post-revprop-change hook:

svnsync --non-interactive copy-revprops  svn:// ${REV} &

This will help propagate things like editing svn:log messages.

And there you go, thats the path I took to mirror one of my repositories onto another machine.

You can svnsync from any repository that you have access to

> sudo svnadmin create /var/www/svn/target-test

> sudo echo <<End > /var/www/svn/target-test/hooks/pre-revprop-change
exit 0

> sudo chmod +x /var/www/svn/target-test/hooks/pre-revprop-change
> sudo svnsync init file:///var/www/svn/target-test/
Copied properties for revision 0 (svn:sync-* properties skipped).

You can only svnsync to a repository with a pre-revprop-change set up

See Project_hosting#Subversion_hosting

Personal tools