aboutsummaryrefslogtreecommitdiff
path: root/handlers/trac
blob: 1c1b46463df33d5801d5c9202fd251ec73050cf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#
# this handler will backup trac environments (based on the svn handler)
#
# http://trac.edgewall.com/
#

getconf src /var/lib/trac
getconf dest /var/backups/trac
getconf tmp /var/backups/trac.tmp

error=0
cd $src
for repo in `find . -name VERSION`
do
    repo=`dirname $repo`

    # Just make the parent directory for $tmp/$repo
    parentdir=`dirname $tmp/$repo`
    ret=`mkdir -p $parentdir 2>&1`
    code=$?
    if [ "$ret" ]; then
       debug "$ret"
    fi
    if [ $code != 0 ]; then
       error "command failed mkdir -p $parentdir"
    fi

    ret=`trac-admin $src/$repo hotcopy $tmp/$repo 2>&1`
    code=$?
    if [ "$ret" ]; then
       debug "$ret"
    fi
    if [ $code != 0 ]; then
       error "command failed -- trac-admin $src/$repo hotcopy $tmp/$repo"
       error=1
    fi
done

if [ $error -eq 1 ]; then
    echo "Error: because of earlier errors, we are leaving trac backups in $tmp instead of $dest"
else
    if [ -d $dest -a -d $tmp ]; then
        rm -rf $dest
    fi
    if [ -d $tmp ]; then
        mv $tmp $dest
    fi
fi

exit 0

# vim: filetype=sh