SVN mirror for Live back-up – High Availability

vishal_vsh1 created the topic: SVN mirror for Live back-up – High Availability
SVN mirror for Live back-up – High Availability

Other then taking backup at regular interval, we may want to provide keep live data just to make sure data is highly available.

The best option is to backup Live data as soon as it gets changed.

Here is the trick for the SVN Mirroring.

How to create Repository
Only user with correct access as admin can create new repository
Identify the repository name and cluster. You must follow the approval process before creating any new repository.
Create repository svnadmin create /svnroot/
change the owner of repository to apache(if needed) chown -R apache:apache /svnroot/
Now you need to create Mirror repository on another SVN server, following are the steps to create “Mirror repository”.

How to create Mirror Repository
Take the hotcopy of the repository from 1st SVN server.
svnadmin hotcopy /svnroot/ /tmp/
Remove the hook script if any
create a tar file of the repo and scp it to 2nd SVN server.
Log in to 2nd server and untar the file.
now again do hotcopy to svnroot location on 2nd server
svnadmin hotcopy /svnroot/

Create 2 hook scripts start-commit and pre-revprop-change on 2st servver, The reason for this is that you can make use of these script to make sure that commit to 2nd server is happening via automated way instead of someone manually committing which you do not want to happen.
Change the owner of repository to apache(if needed) chown -R apache:apache /svnroot/
Now you need to initialize the sync mechanism, login to 1st server.
Go to repository hook location and add following content in post-commit script.
#Calling sync job
TO=//
/svnroot/hook-scripts/sync.sh “$REPOS” “$TO” “2>&1 > /dev/null &

The Above will run after every commit and sync the latest revision to mirror.

Lets assume your main SVN repo is = svn.domain.com
And mirror SVN repo is = svn-mirror.domain.com

content of sync.sh

#!/bin/bash

REPOS=$1
MIRROR=$2

#Replace your username and password
SVNSYNC=/usr/local/bin/svnsync
SYNC_USER=bot
SYNC_PASS=admin
SOURCE_USER=bot
SOURCE_PASS=admin

# Sync to Mirror
$SVNSYNC –non-interactive sync $MIRROR \
–sync-username $SYNC_USER –sync-password $SYNC_PASS \
–source-username $SOURCE_USER –source-password $SOURCE_PASS
if [ $? != 0 ]; then
mail -s “svn sync failed for $REPOS for $MIRROR” your-emain-id@my.com < /dev/null fi create a post-revprop-change script and add above content with following change TO=//
/svnroot/hook-scripts/sync_prop.sh “$REPOS” “$TO” 2>&1 > /dev/null &

Content of sync_prop.sh

#!/bin/bash

REPOS=$1
MIRROR=$2

SVNSYNC=/usr/local/bin/svnsync
SYNC_USER=bot
SYNC_PASS=admin
SOURCE_USER=bot
SOURCE_PASS=admin

# Sync to Mirror
$SVNSYNC –non-interactive copy-revprops $MIRROR \
–sync-username $SYNC_USER –sync-password $SYNC_PASS \
–source-username $SOURCE_USER –source-password $SOURCE_PASS
if [ $? != 0 ]; then
mail -s “svn sync_Prop failed for $REPOS for $MIRROR” yourname@my.com < /dev/null fi Now, you need to initialize the sync, run the following command on Main SVN server(1st one). svnsync initialize // svn.corp.domain.com/ / –sync-username bot –sync-password admin –source-username bot –source-password admin

How to debug the svn sync problem

Usualy sync failed and we get the alert saying the sync is getting failed.
if you try to run the sync manualy it may throw following error.

Failed to get lock on destination repos, currently held by ‘something:db33884a-d10f-11e1-924a-47b0d8d1042f’
This means last sync couldn’t perform the whole action and lock is still hanging for the repo.
In this case you log in to mirror server for which it is failing and run the following command

svn propdel svn:sync-lock –revprop -r 0 //

This will clear the lock and output would be something like “property ‘svn:sync-lock’ deleted from repository revision 0”.

Then you can go and run the manual sync command and it should work now. 🙂

Reference – >www.scmtechblog.net/2015/07/svn-mirror-f…ve-back-up-high.html

Tagged :
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x