X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=backup.sh;h=6f67ee024b5fecc2b620f33b4f3a9f3d78a2def4;hb=e4df5a6ad04b19f05b0a0c6c50a5993ca0b85573;hp=22af67e49d2cc047891e271737776f8cd8a62871;hpb=a8f3c8ffd523aef97eeb688bb284c3a26ba0e050;p=backup.sh diff --git a/backup.sh b/backup.sh index 22af67e..6f67ee0 100755 --- a/backup.sh +++ b/backup.sh @@ -54,17 +54,29 @@ backup() if [ "$backuplevel" = "daglig" ] || [ "$backuplevel" = "incremental" ] then - forrige=`cat ../.date` - forrigecmd="--newer=\"$forrige\"" + lastd=`cat ../.date` + lastcmd="--newer=\"$lastd\"" else - forrigecmd="" + lastcmd="" fi + #if this client has a special tar + #we need to find a better solution to this conf-issue + if [ -f $confdir/tar.$computer ] ; then + tar=`cat $confdir/tar.$computer` + else + tar=tar + fi + + #expand the exclude-path for use with tar + exf=`ssh $computer "ls ~/.backup/exclude"` + #We try to run tar on the remote computer - if `ssh $computer ". /tmp/.backup/env ;\ - cd $filesystem ;\ - \${TAR:-tar} cfl - . $forrigecmd \ - --exclude-from=/tmp/.backup/exclude \ + # C is instead of 'cd $filesystem' + # - is 'this directory' + # l is 'stay in local filesystem + if `ssh $computer "$tar cfCl - $filesystem . $lastcmd \ + --exclude-from=$exf \ | gzip" \ | dd of=$DATE.tmp 2>/dev/null` then @@ -99,32 +111,26 @@ do filesystems="" #Sjekker nest siste felt i fstab. Om det er 0 tar vi ikke backup - filesystems=`ssh -n $computer ". /tmp/.backup/env ; cat /etc/fstab" \ + filesystems=`ssh -n $computer "cat /etc/fstab" \ | grep -v nfs \ | grep -v ^# \ | awk '{ if ( $(NF-1) != "0" ) print $2}' ` #clean up our dir at this client - ssh $computer "rm -rf /tmp/.backup ; mkdir -m 700 /tmp/.backup" + ssh $computer "rm -r ~/.backup ; mkdir -m 700 ~/.backup" #try to copy $exclude to $computer - scp $exclude $computer:/tmp/.backup/exclude || + scp $exclude $computer:~/.backup/exclude || echo "could not copy exclude.txt to $computer :(" - #create env if it does not exist - [ -f $confdir/env.$computer ] || touch $confdir/env.$computer - - #copy env to client - scp $confdir/env.$computer $computer:/tmp/.backup/env - #try to copy preeexec and postexec if they exist [ -f $confdir/preexec.$computer ] && - scp $confdir/preexec.$computer $computer:/tmp/.backup/preexec + scp $confdir/preexec.$computer $computer:~/.backup/preexec [ -f $confdir/postexec.$computer ] && - scp $confdir/postexec.$computer $computer:/tmp/.backup/postexec + scp $confdir/postexec.$computer $computer:~/.backup/postexec #try to run preexec if it exist - ssh $computer ". /tmp/.backup/env ; [ -f /tmp/.backup/preexec ] && /bin/bash -x /tmp/.backup/preexec" + ssh $computer "[ -f ~/.backup/preexec ] && /bin/bash -x ~/.backup/preexec" for filesystem in $filesystems do @@ -183,13 +189,16 @@ do done #try to run postexec if it exist - ssh $computer ". /tmp/.backup/env ; [ -f /tmp/.backup/postexec ] && /bin/bash -x /tmp/.backup/postexec" + ssh $computer "[ -f ~/.backup/postexec ] && /bin/bash -x ~/.backup/postexec" done #create report /home/backup/report.sh $storagedir > /tmp/report.txt -[ ! -z $remotestat ] && scp /tmp/report.txt $remotestat +#[ ! -z $remotestat ] && scp /tmp/report.txt $remotestat ### +# print diskusage to logfile +df -k + date