From: hackbard Date: Sun, 4 Oct 2015 11:06:01 +0000 (+0200) Subject: sync to server, new and first final logic implemented X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=5d9641c81a0cf872ae1e23b2be9b44f78b9aad90;p=outofuni%2Fbackup.git sync to server, new and first final logic implemented --- diff --git a/bin/backup b/bin/backup index 43a1d4c..cf8c584 100755 --- a/bin/backup +++ b/bin/backup @@ -96,6 +96,7 @@ mkdir -p $cbd rsync="rsync -azR --delete --bwlimit=$bandwidth" ob="" +lpb="" for pb in $backupdir/[0-9]*; do bdd=`basename $pb` if [ ! -f $backupdir/.$bdd ]; then @@ -103,42 +104,46 @@ for pb in $backupdir/[0-9]*; do rm -rf $cbd mv $pb $cbd log continuing $pb as $cbd ... - fi - - # if this is a new day backup, i.e.: - # - this is somewhere else!!! - # try to use content as basis - # ... - - 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 - [ ! -z "$homedirs" ] && \ - log backing up home directories $homedirs ... - [ ! -z "$extradirs" ] && \ - log backing up directories $extradirs ... - $rsync $user@$remote$rsrc $cbd - ret=$? - if [ "$ret" != "0" ]; then - log backup terminated before completion ... - exit -50 - fi - - touch $backupdir/.`basename $cbd` - log "backup `basename $cbd` completed :)" - else - if [ "$pb" = "$cbd" ]; then - log backup $bdd found completed ... + else + if [ ! -z "$lpb" ]; then + rm -rf $cbd + mv $lpb $cbd + log "starting backup $today from $lpb ..." + else + log starting backup from scratch ... + fi fi fi + lpb=$pb ob="$ob $pb" done +if [ ! -f $backupdir/.$today ]; then + 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 + [ ! -z "$homedirs" ] && \ + log backing up home directories $homedirs ... + [ ! -z "$extradirs" ] && \ + log backing up directories $extradirs ... + $rsync $user@$remote$rsrc $cbd + ret=$? + if [ "$ret" != "0" ]; then + log backup terminated before completion ... + exit -50 + fi + + touch $backupdir/.$today + log "backup $today completed :)" +else + log backup $bdd found completed ... +fi + cob=`echo $ob | wc -w` if [ $cob -gt $replicas ]; then ((numdel=cob-replicas))