--- /dev/null
+#!/bin/bash
+
+if [ -z "$1" ]; then
+ echo usage: $0 configfile
+ exit -1
+fi
+
+if [ ! -f $1 ]; then
+ echo configfile $1 is not a file
+ exit -2
+fi
+
+config=$1
+
+host=`grep ^host $config | cut -d ' ' -f 2`
+user=`grep ^user $config | cut -d ' ' -f 2`
+homedirs="` grep ^homedirs $config | cut -d ' ' -f 2-`"
+extradirs="`grep ^extradirs $config | cut -d ' ' -f 2-`"
+replicas=`grep ^replicas $config | cut -d ' ' -f 2`
+oldest=`grep ^oldest $config | cut -d ' ' -f 2`
+data=`grep ^data $config | cut -d ' ' -f 2`
+bandwidth=`grep ^bandwidth $config | cut -d ' ' -f 2`
+
+ping -c1 $host > /dev/null 2>&1
+ret=$?
+
+if [ "$ret" = "0" ]; then
+ echo "host $host is online ..."
+else
+ echo "host $host unreachable ..."
+ exit -3
+fi
+
+if [ ! -d $data ]; then
+ echo "no data directory ..."
+ exit -4
+fi
+
+today=`date -I`
+backupdir=$data/${user}_at_${host}
+
+cbd=$backupdir/$today
+mkdir -p $cbd
+
+rsync="rsync -azR --delete --bwlimit=$bandwidth"
+
+ob=""
+for pb in $backupdir/[0-9]*; do
+ bdd=`basename $pb`
+ if [ ! -f $backupdir/.$bdd ]; then
+ if [ "$pb" != "$cbd" ]; then
+ rm -rf $cbd
+ mv $pb $cbd
+ fi
+
+ rsrc=""
+ for dir in $homedirs; do
+ rsrc="$rsrc :/home/$user/$dir"
+ done
+ rsrc="`echo $rsrc | sed 's/^\ //'`"
+ for dir in $extradirs; do
+ rsrc="$rsrc :$dir"
+ done
+ $rsync $user@$host$rsrc $cbd
+ ret=$?
+ [ "$ret" != "0" ] && exit -50
+ touch $backupdir/.$pb
+ fi
+ ob="$ob $pb"
+done
+
+cob=`echo $ob | wc -w`
+if [ $cob -gt $replicas ]; then
+ ((numdel=cob-replicas))
+ todel="`echo $ob | cut -d ' ' -f 1-${numdel}`"
+ echo "to delete: $todel"
+ #for dirdel in $todel; do
+ # bdd=`basename $dirdel`
+ # rm -r $dirdel
+ # rm $backupdir/$bdd
+ #done
+fi
+
+exit 0