#!/bin/bash PATH=/usr/bin:/bin:/usr/sbin:/sbin FRVAL=0 for h in `cat /etc/backup-hamvoip | tr '\n' ' ' 2> /dev/null` do hn=`echo $h | perl -pe 's/^([^\.]+)\..*$/$1/g'` FT="/tmp/$hn.tar" if [ -f $FT ] || [ -f $FT.bz2 ]; then echo "File $FT exists - incomplete run?" exit 1 fi F=`mktemp` mv $F $FT ssh -p 222 -o "PasswordAuthentication no" -o 'StrictHostKeyChecking no' \ root@$h 'cd / && tar cf - etc/ root/ var/lib/asterisk/sounds/rpt/ srv/http/' > $FT RVAL=$? if [ $RVAL != 0 ]; then echo "Error pulling down from $h" rm $FT FRVAL=1 else bzip2 $FT rclone --bind=44.70.48.34 copy $FT.bz2 nextcloud:/Backups/$hn/ RVAL=$? if [ $RVAL != 0 ]; then echo "Error rsyncing $FT.bz2 to nextcloud" FRVAL=1 fi rm $FT.bz2 fi done exit $FRVAL