]> hackdaworld.org Git - outofuni/backup.git/commitdiff
bugfixes + introduced cipher, added hannah config
authorhackbard <hackbard@hackdaworld.org>
Sun, 4 Oct 2015 21:17:46 +0000 (21:17 +0000)
committerhackbard <hackbard@hackdaworld.org>
Sun, 4 Oct 2015 21:17:46 +0000 (21:17 +0000)
bin/backup
config/hannah.conf [new file with mode: 0644]
config/tx2.conf

index 945667cd6db9a97ea0e34efb381523ee56206f0b..191d5be90f8644952ddf3120c237b84f89ab6c26 100755 (executable)
@@ -29,6 +29,8 @@ bandwidth=`grep ^bandwidth $config | cut -d ' ' -f 2`
 bwconn="`grep ^bandwidth $config | cut -d ' ' -f 3-`"
 compression=`grep ^compression $config | cut -d ' ' -f 2`
 compconn="`grep ^compression $config | cut -d ' ' -f 3-`"
+cipher=`grep ^cipher $config | cut -d ' ' -f 2`
+ciconn=`grep ^cipher $config | cut -d ' ' -f 3-`
 logdir=`grep ^logdir $config | cut -d ' ' -f 2`
 
 dolog=0
@@ -74,13 +76,28 @@ if [ ! -z "$bandwidth" ]; then
                ch=`echo $bwpair | cut -d ':' -f 1`
                if [[ "$remote" == "$ch"* ]]; then
                        bwl=`echo $cpair | cut -d ':' -f 2`
-                       [ ! -z "$bwl" ]] && bw=$bwl
+                       [ ! -z "$bwl" ] && bw=$bwl
                fi
        done
 fi
-rbw="--bandwidth=$bw"
+rbw="--bwlimit=$bw"
 log applying bandwidth of $bw ...
 
+ciph=""
+if [ ! -z "$cipher" ]; then
+       ciph=$cipher
+       for cipair in "$ciconn"; do
+               ch=`echo $cipair | cut -d ':' -f 1`
+               if [[ "$remote" == "$ch"* ]]; then
+                       cl=`echo $cipair | cut -d ':' -f 2`
+                       [ ! -z "$cl" ] && ciph=$cl
+               fi
+       done
+fi
+if [ ! -z "$ciph" ]; then
+       log using cipher $ciph ...
+fi
+
 if [ ! -d $data ]; then
        log no data directory ...
        exit -4
@@ -89,33 +106,36 @@ log backing up to $data ...
 
 today=`date -I`
 backupdir=$data/${user}_at_${host}
-
 cbd=$backupdir/$today
-mkdir -p $cbd
-
-rsync="rsync -azR --delete --bwlimit=$bandwidth"
 
 ob=""
 lpb=""
 for pb in $backupdir/[0-9]*; do
+       [ ! -d $pb ] && continue
        bdd=`basename $pb`
        if [ ! -f $backupdir/.$bdd ]; then
                if [ "$pb" != "$cbd" ]; then
                        rm -rf $cbd
                        mv $pb $cbd
                        log continuing $pb as $cbd ...
-               else
-                       if [ ! -z "$lpb" ]; then
-                               rm -rf $cbd
-                               cp -r $lpb $cbd
-                               log "starting backup $today from $lpb ..."
-                       fi
                fi
+       else
+               lpb=$pb
+               ob="$ob $pb"
        fi
-       lpb=$pb
-       ob="$ob $pb"
 done
 
+
+if [ ! -d $cbd ]; then
+       if [ ! -z "$lpb" ]; then
+               cp -r $lpb $cbd
+               log starting backup $today from $lpb ...
+       else
+               mkdir -p $cbd
+               log starting backup $today from scratch ...
+       fi
+fi
+
 if [ ! -f $backupdir/.$today ]; then
        rsrc=""
        for dir in $homedirs; do
@@ -129,7 +149,15 @@ if [ ! -f $backupdir/.$today ]; then
                log backing up home directories $homedirs ...
        [ ! -z "$extradirs" ] && \
                log backing up directories $extradirs ...
-       $rsync $user@$remote$rsrc $cbd
+
+       if [ -z "$ciph" ]; then
+               rsync=(rsync -aR $rcomp --delete $rbw $user@$remote$rsrc $cbd)
+       else
+               rsync=(rsync -aR -e "ssh -c $ciph" $rcomp --delete)
+               rsync+=($rbw $user@$remote$rsrc $cbd)
+       fi
+       "${rsync[@]}"
+
        ret=$?
        if [ "$ret" != "0" ]; then
                log backup terminated before completion ...
diff --git a/config/hannah.conf b/config/hannah.conf
new file mode 100644 (file)
index 0000000..167a60c
--- /dev/null
@@ -0,0 +1,11 @@
+host hannah
+aliases hannahvpn
+user stoffl
+homedirs Dokumente Bilder Projekte bin .config
+extradirs 
+replicas 3
+oldest 60
+data /mnt/wd/ext/backups
+bandwidth 10m hannahvpn:5m
+compression 0 hannahvpn:4
+logdir /mnt/wd/ext/backups/log
index 23ce69b7527c058be64ca1a8d31a71233d4dd9e0..6baa4c4c1be15e013d52be49ab65f161e13f44d0 100644 (file)
@@ -2,10 +2,11 @@ host tx2
 aliases tx2vpn
 user hackbard
 homedirs .config bin briefe moritz private projects ssl
-extradirs /scratch 
+extradirs /home/scratch
 replicas 3
 oldest 60
 data /mnt/wd/ext/backups
-bandwidth 20m tx2vpn:5m
+bandwidth 10m tx2vpn:5m
 compression 1 tx2vpn:4
+cipher arcfour
 logdir /mnt/wd/ext/backups/log