]> hackdaworld.org Git - outofuni/backup.git/commitdiff
sync to server, new and first final logic implemented
authorhackbard <hackbard@hackdaworld.org>
Sun, 4 Oct 2015 11:06:01 +0000 (13:06 +0200)
committerhackbard <hackbard@hackdaworld.org>
Sun, 4 Oct 2015 11:06:01 +0000 (13:06 +0200)
bin/backup

index 43a1d4c1aff9b00528f504c1a7b99d9e69c440b0..cf8c58463242a3173d45d802691adf2625d3b36a 100755 (executable)
@@ -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))