Sync Subversion between two different servers

×

Error message

  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home4/ccollins/public_html/ccollins/includes/common.inc).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /home4/ccollins/public_html/ccollins/includes/menu.inc).

I had a need to back up my repo to another server. I already back up the repository to an external dive but i thought this would be an even better solution. To have a hot backup!

After searching google for a wile i found a article that fit the bill.
https://journal.paul.querna.org/articles/2006/09/14/using-svnsync/

While i have version 1.6.11 it still worked great!

The only thing that i did differently was create a user in the repo to run this as.

So, to make this easier, I am going to put the repository URIs into environment variables:


$ export FROMREPO=svn://svn.example.com/
$ export TOREPO=svn://dest.example.com/

Because the svnsync is allowed to rewrite anything on the TOREPO, we need to make sure the commit hooks are configured to allow our 'svnsync' user to do anything it wants.

On the server hosting TOREPO, I ran this:

$ echo "#!/bin/sh" > hooks/pre-revprop-change
$ chmod 755 hooks/pre-revprop-change

Now we are ready to setup the sync:

$ 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

$ svn propget svn:sync-from-url --revprop -r 0 ${TOREPO}

svn://svn.example.com/

So all the knowledge about what we are syncing from is stored at the destination repository. No state about this sync is stored in the source repository.

We are now ready to begin copying data:


$ svnsync --non-interactive sync ${TOREPO}