Svnsync

From WhyNotWiki
Jump to: navigation, search

Contents

http://bob.pythonmac.org/archives/2006/09/14/svnsync-mirror-your-svn-repository/

$ svnadmin create svn.mochikit.com
$ svnsync init file://$PWD/svn.mochikit.com http://svn.mochikit.com/
$ svnsync sync file://$PWD/svn.mochikit.com

The example performs the following tasks:

  • Creates a new local repository named svn.mochikit.com
  • Initializes the (local) svn.mochikit.com repository to be a mirror of (remote) http://svn.mochikit.com/
  • Synchronizes the svn.mochikit.com 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).

http://svn.collab.net/repos/svn/trunk/notes/svnsync.txt


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?

http://journal.paul.querna.org/articles/2006/09/14/using-svnsync


$ 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}

  svn:sync-from-uuid
  svn:sync-last-merged-rev
  svn:date
  svn:sync-from-url

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

http://journal.paul.querna.org/articles/2006/09/14/using-svnsync


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://dest.example.com/ &

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://dest.example.com/ ${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
#!/bin/sh
exit 0
End

> sudo chmod +x /var/www/svn/target-test/hooks/pre-revprop-change
> sudo svnsync init file:///var/www/svn/target-test/ https://rake-completion.googlecode.com/svn/
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

Ads
Personal tools