You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Abha Shrimal <ab...@rediffmail.com> on 2006/11/03 04:12:27 UTC

Subversion Backup

Hi All,

How can we decide on the frequency of backing up Subversion repository. Whether it should be on hourly basis or daily or weekly or monthly ? Please help me on deciding the the frequency of taking backup of Subversion repository so that even if the subversion server goes down we can restore the same from the backup without much loss of data and everything is safe and sound as before.

Thanks,
Abha.

Re: Subversion Backup

Posted by Mark Kempster <ma...@kempster.org>.
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

Re: Subversion Backup

Posted by Thomas Harold <tg...@tgharold.com>.
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.)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Subversion Backup

Posted by Mark Kempster <ma...@kempster.org>.

On Tue, 7 Nov 2006, Gavin Lambert wrote:

> Quoth Abha Shrimal <ma...@rediffmail.com>:
> > How can we decide on the frequency of backing up Subversion
> > repository. Whether it should be on hourly basis or daily or weekly
> > or monthly ? Please help me on deciding the the frequency of taking
> > backup of Subversion repository so that even if the subversion server
> > goes down we can restore the same from the backup without much loss
> > of data and everything is safe and sound as before.
>
> That depends entirely on the frequency of committing that you do, and
> how much data you're willing to lose/reconstruct.
>
> If you only commit weekly, then backing up more frequently than that
> isn't going to do you any good.  If you commit hourly, but only back up
> weekly, then you have to be prepared to recreate everything you've done
> that week if you have to restore the backup.  It's a balancing act,
> which only you can decide on.

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:

(1) post-commit hook that svnadmin hotcopy's to a local directory
  - hotcopy only works when there's something to work on
(2) hourly 'rsync -av --checksum /backups/svnhotcopy/
remote:/backups/svnhotcopy'
  - rsync only copies across the things that changed.

Worst case, your remote backup's only an hour old.

If you have reliable nfs or some such, you might consider doing the
post-commit-hotcopy directly to the remote disk?

Cheers
- Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Subversion Backup

Posted by Gavin Lambert <ga...@compacsort.com>.
Quoth Abha Shrimal <ma...@rediffmail.com>:
> How can we decide on the frequency of backing up Subversion
> repository. Whether it should be on hourly basis or daily or weekly
> or monthly ? Please help me on deciding the the frequency of taking
> backup of Subversion repository so that even if the subversion server
> goes down we can restore the same from the backup without much loss
> of data and everything is safe and sound as before.     

That depends entirely on the frequency of committing that you do, and
how much data you're willing to lose/reconstruct.

If you only commit weekly, then backing up more frequently than that
isn't going to do you any good.  If you commit hourly, but only back up
weekly, then you have to be prepared to recreate everything you've done
that week if you have to restore the backup.  It's a balancing act,
which only you can decide on.

Having said that, I don't think backing up monthly is a good idea,
unless you really do only seldom make changes.  Not too many people can
remember everything they've done in the last month of work :)


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org