chiark / gitweb /
sort files numerically
[bin.git] / svn-backup
1 #! /bin/sh
2
3 REPOS="$1"
4 DUMP="$2"
5 OWNER="$3"
6 if [ -z "$REPOS" ] || [ -z "$DUMP" ]; then
7     echo "Usage: $0 repository dump-prefix [repository-owner]" >&2
8     exit 1
9 fi
10
11 if [ -n "$OWNER" ]; then
12     SVNADMIN="sudo -u $OWNER svnadmin"
13     SVNLOOK="sudo -u $OWNER svnlook"
14 else
15     SVNADMIN=svnadmin
16     SVNLOOK=svnlook
17 fi
18
19 REV=`$SVNLOOK youngest "$REPOS"`
20 if [ "`expr "$REV" : '[0-9]\+'`" -eq 0 ]; then
21     echo "$0: svnlook youngest failed" >&2
22     exit 1
23 fi
24
25 if [ -f "$DUMP.$REV" ] || [ -f "$DUMP.$REV.bz2" ]; then
26     exit 0
27 else
28     $SVNADMIN dump --quiet "$REPOS" -r 0:"$REV" > "$DUMP.$REV"
29     bzip2 "$DUMP.$REV"
30 fi
31
32 exit 0