fixed bug when system has multiple usernames starting with "root".
[matthijs/upstream/backupninja.git] / handlers / svn
1 #
2 # this handler will backup subversion repostitories.
3 #
4
5 getconf src /var/lib/svn
6 getconf dest /var/backups/svn
7 getconf tmp /var/backups/svn.tmp
8 getconf HOTBACKUP /usr/lib/subversion/hot-backup.py
9
10 error=0
11 cd $src
12 for repo in `find . -name svnserve.conf`
13 do
14     repo=`dirname $repo`
15     repo=`dirname $repo`
16
17     ret=`mkdir -p $tmp/$repo 2>&1`
18     code=$?
19     if [ "$ret" ]; then
20        debug "$ret"
21     fi
22     if [ $code != 0 ]; then   
23        error "command failed mkdir -p $tmp/$repo"
24     fi
25
26     ret=`$HOTBACKUP $src/$repo $tmp/$repo 2>&1`
27     code=$?
28     if [ "$ret" ]; then
29        debug "$ret"
30     fi
31     if [ $code != 0 ]; then
32        error "command failed -- $HOTBACKUP $src/$repo $tmp/$repo"
33        error=1
34     fi
35 done
36
37 if [ $error ]; then
38     echo "Error: because of earlier errors, we are leaving svn backups in $tmp instead of $dest"
39 else
40     if [ -d $dest -a -d $tmp ]; then
41         rm -rf $dest
42     fi
43     if [ -d $tmp ]; then
44         mv $tmp $dest
45     fi
46 fi
47
48 exit 0