[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Subversion Backup

From: Mark Kempster <mark_at_kempster.org>
Date: 2006-11-08 22:00:53 CET

On Wed, 8 Nov 2006, Thomas Harold wrote:

> Mark Kempster wrote:
> >
> > I also ran into this recently. Especially after reading about members of
> > this list having problems reconstructing a repository from a backup that
> > was slightly old (and dealing with synchronizing working copies). I
> > decided to take a first pass at backup infrastructure like so:
>
> I think, if I'm reading the tea leaves correctly, that synchronization
> of local working copies will be getting improvements in the 1.5 (or
> later) version of SVN? Or at least SVN will be more graceful about
> recovering from such an event?
>
> (I've also been nervously watching those threads as well that dealt with
> repository restores and the working copy out-of-sync issues. I still
> haven't decided on a backup strategy beyond a daily hotcopy.)
>

On the offchance it helps, here are the two pieces of the
post-commit-hotcopy that I ended up implementing - thanks to members of
this list who made it all possible.

In repos/hooks/post-commit:

------------------------------------------------------------------------
reposLogDir="/opt/log"
reposName=`/bin/basename ${REPOS}`
postcommitLog="${reposLogDir}/${reposName}-postcommit.log"
hostname=`hostname`
backupDir="/backups/${hostname}"
# Call to hotcopy.sh should be all one line...
${REPOS}/hooks/hotcopy.sh "${REPOS}" "${REV}" "${backupDir}" "${postcommitLog}" >/dev/null 2>/dev/null &
------------------------------------------------------------------------

And hotcopy.sh
------------------------------------------------------------------------
#!/bin/sh

# Export the repository into a chroot-style directory structure
# under backupDir. eg. /opt/repos becomes /backups/hostname/opt/repos
# Restoring looks something like 'cp -a /backups/${hostname}/* /'

REPOS="$1"
VER="$2"
backupDir="$3"
LOG="$4"

echo "`date` - Starting hotcopy repos $REPOS to ${backupDir}/${REPOS}.${VER}" >> $LOG

# Export to repos.123 (can be slow) to avoid clashes with parallel commits
if [ ! -d ${backupDir}/${REPOS}.${VER} ] ; then
  echo "creating ${backupDir}${REPOS}.${VER}"
  mkdir -p ${backupDir}/${REPOS}.${VER}
fi
/usr/bin/svnadmin hotcopy "${REPOS}" "${backupDir}/${REPOS}.${VER}" >> $LOG

echo "`date` - Finished hotcopy" >> $LOG

echo "`date` - Rotating export directories ${backupDir}/${REPOS}.${VER} to ${backupDir}/${REPOS}" >> $LOG
# rename repos.123 to repos (should be fast). Most recent commit wins
# (theoretically).
rm -rf "${backupDir}/${REPOS}"
mv "${backupDir}/${REPOS}.${VER}" "${backupDir}/${REPOS}"

echo "`date` - Export process complete." >> $LOG
------------------------------------------------------------------------

Just about anybody who reads this will notice that there are lots
of echo statements, no parameter checking, etc...

It's a step in the right direction from nightly-export, but is only
that.

Cheers
- Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Nov 8 21:53:49 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.