Bacula-users

[Bacula-users] Hope usefull script if you know % of progress backup

2009-08-14 05:13:29
Subject: [Bacula-users] Hope usefull script if you know % of progress backup
From: Fabio Xarax <fxarax AT gmail DOT com>
To: bacula-users <bacula-users AT lists.sourceforge DOT net>
Date: Fri, 14 Aug 2009 11:03:27 +0200
Hi All!
I hope thi can be usefull
the script return lines like this
 
JobId= 5257 <JOBNAME> <CLIENT> | Now:  58.81%  Files=217437 Bytes=224761256596 Bytes/sec=7269592 Errors=3  (on tot.byte= 382146782310) 08:35:18        <-- duration
JobId= 5226 <JOBNAME> <CLIENT> | Now:  73.15%  Files=1580436 Bytes=217781667592 Bytes/sec=5045914 Errors=0  (on tot.byte= 297702961761) 11:59:20
Here you are and pls, let me know ;)
Fabio
 
 
#!/bin/bash
#
# Script to know the progress of running bck
#        using by -u for updating client list/estimate
#
# By CHIECHI Fabio
# (c) 2009
#
chcpath=/filedisk/chc/tmp
bindir=/usr/bin
db_name=${db_name:-bacula}
if [ ! -f $bindir/mysql ]; then
   echo -e "Sorry, Script for MySQL!\nI can't find MySQL :("
   exit 1
fi
case "$1" in
   -u|update|-update|upd|-upd)
      rm -f $chcpath/bacula_estratto_estimate.txt
      bconsole <<END-OF-DATA | grep -v Enter | grep -v 1000 | grep -v client | sort -u > $chcpath/bacula_lista_client.txt
.client
END-OF-DATA
      cat $chcpath/bacula_lista_client.txt | while read line
      do
         echo $line
         esito=$(bconsole <<END-OF-DATA| grep "OK estimate"
estimate job=$line.j
END-OF-DATA)
         echo $esito
         echo $line $esito | awk '{print $1 "   bytes = "  substr($6,7,20) "   files = " substr($5,7,20)}' | sed "s/,//g" >> $chcpath/bacula_estratto_estimate.txt
      done
      rm -f $chcpath/bacula_lista_client.txt
      ;;
   *)
      if [ ! -f $chcpath/bacula_estratto_estimate.txt ]; then
         echo "I can't find estimate data."
         echo "Run the scrpt with -u option!"
         exit 1
      fi
      $bindir/mysql -f <<END-OF-DATA | grep -v "JobId" | while read line
USE ${db_name};
select JobId,Job,Client.Name from Job inner join  Client on Job.ClientId = Client.ClientId where Job.JobStatus='R';
END-OF-DATA
      do
         JBID=$(echo $line |awk '{print $1}')
         SRV=$(echo $line |awk '{print $3}')
         esito=$(bconsole <<END-OF-DATA| grep "Files=" | sed "s/,//g"
status client=$SRV
END-OF-DATA)
         battuali=$(echo $esito | awk '{print $2}'|cut -d "=" -f 2)
         btot=$(cat ${chcpath}/bacula_estratto_estimate.txt | grep $SRV | awk '{print $4}')
         if [ "$btot" == "" ]; then
            echo "client doesn't exists in estimate data!"
         else
            perc=$(echo "scale=2; $battuali * 100 / $btot" | bc)
            adata=$(date '+%Y-%m-%d %H:%M:%S')
            durata=$($bindir/mysql -f <<END-OF-DATA | grep -v timediff
USE ${db_name}
select timediff('$adata',Job.StartTime) from Job where JobId='$JBID'
END-OF-DATA)
            echo "JobId= "$line "| Now: " $perc"% " $esito " (on tot.byte= "$btot")" $durata
         fi
      done
      ;;
esac
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users
<Prev in Thread] Current Thread [Next in Thread>
  • [Bacula-users] Hope usefull script if you know % of progress backup, Fabio Xarax <=