Backing up Subversion
This might still be useful to someone, so I'm leaving it here. If you want a more robust, complete solution, check out CedarBackup.
I run a weekly full backup and a daily incremental backup of the Subversion repositories. The Subversion backend is a BDB (Berkeley) database, but you don't need to know that. Instead, you write a script in terms of the svnlook and svnadmin programs.
Incremental backups are fairly simple. Basically, svnlook can be used to tell you the youngest repository revision, and then you dump from the repository for every revision between that one and the last one you backed up.
You do the dump in the text-based format, so this is even good for restoring to a newer version of Subversion if you need to.
I can't offer a complete script to do this, but here's a kshell fragment from my own backup scripts:
for REPOS in ${REPOS_LIST}
do
REPOS_PATH=/opt/public/svn/${REPOS}
LAST_REV_PATH=/opt/backup/tmp/svn-last.${REPOS}
if [" "${TODAYDOW}" = "${STARTDOW}" "]
then
START_REV=0
END_REV=$(svnlook youngest ${REPOS_PATH})
DUMP_PATH=/opt/backup/collect/svndump.${REPOS}.full.bz2
else
if [" -f ${LAST_REV_PATH} "]
then
LAST_REV=$(cat ${LAST_REV_PATH} 2>/dev/null)
START_REV=$((LAST_REV+1))
END_REV=$(svnlook youngest ${REPOS_PATH})
DUMP_PATH=/opt/backup/collect/svndump.${REPOS}.${START_REV}-${END_REV}.bz2
else
START_REV=0
END_REV=$(svnlook youngest ${REPOS_PATH})
DUMP_PATH=/opt/backup/collect/svndump.${REPOS}.full.bz2
fi
fi
if [" "${START_REV}" -ge "${END_REV}" "]
then
# Skip this repository
continue
fi
svnadmin dump -r${START_REV}:${END_REV} --incremental ${REPOS_PATH} 2>/dev/null | bzip2 > ${DUMP_PATH}
if [" $? != 0 "]
then
print "Subversion dump failed for ${REPOS_PATH}."
exit 1
fi
chown backup:backup ${DUMP_PATH}
echo "${END_REV}" > ${LAST_REV_PATH}
done