summaryrefslogtreecommitdiff
blob: 95bf9f77f2b38699e87bb66b2e77fc0a37d01541 (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
#!/bin/bash

if [ "x$1" == "x--help" ]; then
  echo "Usage: SVN-html /backup/dir \"commit message\""
  echo
  echo "Copies the /var/www directory into the given /backup/dir/html"
  echo "and subsequently performs a \"svn commit\". So the "
  echo "backup dir has to be a checkout from an svn repository."
  exit 0
fi

LOGFILE=${1}/cronlog
ERRFILE=${1}/errlog
BASEDIR=${1}/html/

if [ ! -d "${BASEDIR}" ]; then
    mkdir -p $BASEDIR
    cd ${1} && svn add html
fi

date > $LOGFILE
date > $ERRFILE

rsync -rptgo --delete-after  --exclude ".svn/" /var/www/ $BASEDIR 2>> $ERRFILE | grep -v "skipping"
cd $BASEDIR && TL=`find .` && for fl in $TL;do [ -L $fl ] && rm $fl;done
cd $BASEDIR && svn status | grep '^!' | sed -e 's/^!//' | sed -e "s/^ *//" | sed -e 's/ /\\ /g' | xargs svn rm &> $LOGFILE
cd $BASEDIR && svn status | grep '^?' | sed -e 's/^?//' | sed -e "s/^ *//" | sed -e 's/ /\\ /g' | xargs svn add &> $LOGFILE

MESSAGE="$2"
[ ! "$MESSAGE" ] && MESSAGE="Automatic Update"
cd $BASEDIR >> $LOGFILE 2>> $ERRFILE && svn commit -m "$MESSAGE"  >> $LOGFILE 2>> $ERRFILE 

cat $LOGFILE
cat $ERRFILE

rm $LOGFILE
rm $ERRFILE