You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Bailey, Darragh" <db...@hp.com> on 2010/02/02 17:42:44 UTC
Svnsync - switching source and mirror
Looking to setup a mirror to a locally hosted svn repo, however it's expected that in the future the role of which repo is the mirror and which is the master will reverse.
Reading up on svnsync, there appears to be some suggestion that something happens with the 'svnsync init' command that is specific to the new mirror. I'm wondering if this will be an issue when changing which repo is the master and which is the mirror?
It's not clear what exactly is set by this initial command. AFAICT it's only the last changed datestamp on rev 0, i.e. the initial create time of the source repository. It doesn't appear to copy the UUID, or provide an option to copy this, although maybe that's just because of the version I'm testing this on (1.4).
What I'm looking to achieve is the following:
Setup a remote read-only mirror for another team, and then at a later stage change to having this be the master and change our local svn repo to be a read-only mirror of the remote system.
Some ASCII diagrams:
Current:
Team 1
/--------\
| Master |
\--------/
Next step: Setup remote read-only mirror for team 2
Team 1 Team 2
/--------\ /--------\
| Master | ---------> | Mirror |
\--------/ \--------/
Final stage: switch which is master and which is mirror
Team 1 Team 2
/--------\ /--------\
| Mirror | <--------- | Master |
\--------/ \--------/
While there seems to be plenty of documentation on setting up the mirror using svnsync, I haven't seen anything on whether anything special needs to be done to convert the mirror to a proper repo.
Based on what I want to do, below are the steps that I think I need to follow. Would appreciate any pointers to something that I've missed or any gotcha's that I've overlooked.
First stage: setting up the mirror
1) Create a svnsync user on both local and remote systems (might as well create it now on the local system)
2) Create a svn repository on the remote system
svnadmin create /var/svn/mirror
3) Setup pre-revprop-change and pre-commit scripts to let only svnsync user edit the mirror repo
/var/svn/mirror/hooks/pre-revprop-change
#!/bin/sh
USER="$3"
if [ "$USER" = "svnsync" ]; then exit 0; fi
echo "Only the svnsync user can change revprops" >&2
exit 1
/var/svn/mirror/hooks/pre-commit
#!/bin/sh
REPOS="$1"
TXN="$2"
USER=`/usr/local/bin/svnlook author -t "$TXN" "$REPOS"`
if [ "$USER" = "svnsync" ]; then exit 0; fi
echo "This is a mirror repository only, please commit to the master"
exit 1
4) From the local system init the repository with svnsync
svnsync init --username svnsync svn+ssh://remote/var/svn/mirror file:///var/svn/master
5) Synchronise the repositories
svnsync synchronize --username svnsync svn+ssh://svnsync@remote/var/svn/mirror
6) Put the local repo into read-only mode temporarily and repeat step 6 (since otherwise it would read-only for many hours)
Do this by setting at the top of the scripts
/var/svn/master/hooks/{pre-commit,pre-revprop-change}
echo "Repository temporarily read only contact blah if this is an issue"
exit 1
7) Add post-commit and post-rev-changes to forward and future changes to the master repository to the
/var/svn/master/hooks/post-commit
/usr/local/bin/svnsync synchronize --username svnsync svn+ssh://svnsync@remote/var/svn/mirror &
/var/svn/master/hooks/post-rev-change
REV="$2"
/usr/local/bin/svnsync copy-revprops --username svnsync svn+ssh://svnsync@remote/var/svn/mirror $REV &
8) Copy the repo UUID from the master to the mirror
Otherwise users can't checkout the mirror, do a svn --relocate and commit to the master
Local system
svnadmin dump -r0 /var/svn/master | head -n 3 > saved-uuid
Remote system
svnadmin load --force-uuid /var/svn/mirror < saved-uuid
Switching the role of mirror and master
9) Set current master to read-only
i.e. Take the pre-commit and pre-rev-prop from step 3 and add them to the master hooks directory
10) Add scripts to the mirror to forward changes made to the former master repo
/var/svn/mirror/hooks/post-commit
/usr/local/bin/svnsync synchronize --username svnsync svn+ssh://svnsync@local/var/svn/master &
/var/svn/mirror/hooks/post-rev-change
REV="$2"
/usr/local/bin/svnsync copy-revprops --username svnsync svn+ssh://svnsync@local/var/svn/master $REV &
11) Remove the changes made to the post-commit and post-rev-change scripts on the original master
These were change changes made in step 7
12) Remove the tests is pre-revprop-change and pre-commit on the mirror for the user svnsync
These were the tests added in step 3 to only allow svnsync to update the mirror repository
Once removed the former remote mirror is now expected to be the target repository for future commits.
Have I covered everything here?
Is there something that "svnsync init" in step 4 does to the mirror repository that will have to be undone before it can be used as a normal repository and also replicated on the original master before it can be used as a read-only mirror?
--
Regards,
Darragh Bailey
Systems Software Engineer
Hewlett Packard Galway Ltd.
Postal Address: Hewlett Packard Galway Limited, Ballybrit Business Park, Galway
Registered Office: Hewlett Packard Galway Limited, 63-74 Sir John Rogerson's Quay Dublin 2
Registered Number: 361933
RE: Svnsync - switching source and mirror
Posted by "Bailey, Darragh" <db...@hp.com>.
Some typo's in my mail that I didn't spot the first time
> 5) Synchronise the repositories
> svnsync synchronize --username svnsync
> svn+ssh://svnsync@remote/var/svn/mirror
>
> 6) Put the local repo into read-only mode temporarily and
> repeat step 6 (since otherwise it would read-only for many hours)
> Do this by setting at the top of the scripts
> /var/svn/master/hooks/{pre-commit,pre-revprop-change}
> echo "Repository temporarily read only contact blah if this
> is an issue"
> exit 1
Start of 6 should have read
"6) Put the local repo into read-only mode temporarily and repeat step 5"
> 7) Add post-commit and post-rev-changes to forward and future
> changes to the master repository to the
> /var/svn/master/hooks/post-commit
> /usr/local/bin/svnsync synchronize --username svnsync
> svn+ssh://svnsync@remote/var/svn/mirror &
>
> /var/svn/master/hooks/post-rev-change
> REV="$2"
> /usr/local/bin/svnsync copy-revprops --username svnsync
> svn+ssh://svnsync@remote/var/svn/mirror $REV &
End of step 7 should have been remove the read-only changes made in step 6 from the local master. Otherwise, as I'm sure someone will point out, you won't be able to commit to the master.
--
Regards,
Darragh Bailey
Systems Software Engineer
Hewlett Packard Galway Ltd.
Postal Address: Hewlett Packard Galway Limited, Ballybrit Business Park, Galway
Registered Office: Hewlett Packard Galway Limited, 63-74 Sir John Rogerson's Quay Dublin 2
Registered Number: 361933
RE: Svnsync - switching source and mirror
Posted by "Bailey, Darragh" <db...@hp.com>.
> -----Original Message-----
> From: C. Michael Pilato [mailto:cmpilato@collab.net]
> Sent: 02 February 2010 17:58
> To: Bailey, Darragh
> Cc: users@subversion.apache.org
> Subject: Re: Svnsync - switching source and mirror
> All that 'svnsync init' does is set a bunch of revision
> properties on r0 in
> the new mirror repository.
>
> $ svn plist -v -r0 --revprop file:///usr/local/svn/subversion
> Unversioned properties on revision 0:
> svn:sync-from-uuid
> 612f8ebc-c883-4be0-9ee0-a4e9ef946e3a
> svn:sync-last-merged-rev
> 39208
> svn:date
> 2001-08-31T04:23:30.644170Z
> svn:sync-from-url
> http://svn.collab.net/repos/svn
> $
>
> To switch your notion of "source" and "sync" repository,
> you'll need to set
> similar properties on the new "sync" repository. But you'll
> have to do so
> by hand (using 'svn pedit' or 'svn pset'), because 'svnsync
> init' gets fussy
> if you aren't operating on a clean repository. (In
> Subversion's trunk --
> that is, 1.7.0-to-be -- I've added an --allow-non-empty
> option to 'svnsync
> init' which allows you to init an already populated copy of a
> repository as
> a mirror of the original. No more hand-editing of those revprops.)
>
> --
> C. Michael Pilato <cm...@collab.net>
> CollabNet <> www.collab.net <> Distributed
> Development On Demand
Doh! Forgot to use the --revprop option, that's why I didn't see anything being set.
Thanks for the info, that should allow me to complete my documentation here for how to get this working correctly.
--
Regards,
Darragh Bailey
Systems Software Engineer
Hewlett Packard Galway Ltd.
Postal Address: Hewlett Packard Galway Limited, Ballybrit Business Park, Galway
Registered Office: Hewlett Packard Galway Limited, 63-74 Sir John Rogerson's Quay Dublin 2
Registered Number: 361933
Re: Svnsync - switching source and mirror
Posted by "C. Michael Pilato" <cm...@collab.net>.
Bailey, Darragh wrote:
> Looking to setup a mirror to a locally hosted svn repo, however it's
> expected that in the future the role of which repo is the mirror and
> which is the master will reverse.
>
> Reading up on svnsync, there appears to be some suggestion that something
> happens with the 'svnsync init' command that is specific to the new
> mirror. I'm wondering if this will be an issue when changing which repo
> is the master and which is the mirror?
>
> It's not clear what exactly is set by this initial command. AFAICT it's
> only the last changed datestamp on rev 0, i.e. the initial create time of
> the source repository. It doesn't appear to copy the UUID, or provide an
> option to copy this, although maybe that's just because of the version
> I'm testing this on (1.4).
All that 'svnsync init' does is set a bunch of revision properties on r0 in
the new mirror repository.
$ svn plist -v -r0 --revprop file:///usr/local/svn/subversion
Unversioned properties on revision 0:
svn:sync-from-uuid
612f8ebc-c883-4be0-9ee0-a4e9ef946e3a
svn:sync-last-merged-rev
39208
svn:date
2001-08-31T04:23:30.644170Z
svn:sync-from-url
http://svn.collab.net/repos/svn
$
To switch your notion of "source" and "sync" repository, you'll need to set
similar properties on the new "sync" repository. But you'll have to do so
by hand (using 'svn pedit' or 'svn pset'), because 'svnsync init' gets fussy
if you aren't operating on a clean repository. (In Subversion's trunk --
that is, 1.7.0-to-be -- I've added an --allow-non-empty option to 'svnsync
init' which allows you to init an already populated copy of a repository as
a mirror of the original. No more hand-editing of those revprops.)
--
C. Michael Pilato <cm...@collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand