--- smeserver-affa-0.9.0/root/sbin/e-smith/affa.trapsignals 2008-03-09 12:22:22.000000000 +0100 +++ smeserver-affa-0.9.0/root/sbin/e-smith/affa 2008-03-09 13:15:31.000000000 +0100 @@ -2490,6 +2490,12 @@ my $affastatus = esmith::DB::db->open("/home/e-smith/db/affa-report/$jobname"); my $size=$affastatus->get_prop( $archive, 'TotalFileSize' ) || 0; + if( not $size ) + { + updateReportDB(); + $affastatus = esmith::DB::db->open("/home/e-smith/db/affa-report/$jobname"); + $size=$affastatus->get_prop( $archive, 'TotalFileSize' ) || 0; + } $size =~ s/(\d*).*/$1/; my $f; my $restore_list=''; --- smeserver-affa-0.9.0/root/usr/lib/affa/create-backup-file.sh.trapsignals 2008-03-09 12:24:13.000000000 +0100 +++ smeserver-affa-0.9.0/root/usr/lib/affa/create-backup-file.sh 2008-03-09 13:13:41.000000000 +0100 @@ -14,36 +14,58 @@ BASENAME=`basename $OUTFILE` SIZE=$6 -PIPE=/tmp/affa.$$.$(date +%s) -mkfifo $PIPE + +errorexit() + { + STATUS=$? + if [ ! -z $1 ] ; then + STATUS=$1 + fi + echo + test -f $OUTFILE && rm -f $OUTFILE + rm -f $OUTFILE.md5sum $PIPE + exit $STATUS + } + +verifyint() + { + echo "Verify terminated by user" + rm -f $OUTFILE.md5sum $PIPE + exit 0 + } + +trap errorexit SIGTERM SIGINT ERR echo "Writing $OUTFILE" -(md5sum < $PIPE & /bin/tar -C $ROOTDIR/$JOB/$ARCHIVE -cf - $RESTORE | /usr/bin/pv -i 0.3 -s $SIZE | /bin/gzip | tee $PIPE > $OUTFILE) > $OUTFILE.md5sum +PIPE=/tmp/affa.$$.$(date +%s) +rm -f $PIPE +mkfifo $PIPE +(md5sum < $PIPE & /bin/tar -C $ROOTDIR/$JOB/$ARCHIVE -cf - $RESTORE | /usr/bin/pv -i 0.3 -s $SIZE | /bin/gzip --fast | tee $PIPE > $OUTFILE) > $OUTFILE.md5sum STATUS=$? if [ $STATUS != 0 ] ; then - test -f $OUTFILE && rm -f $OUTFILE - rm -f $OUTFILE.md5sum $PIPE - exit $STATUS + errorexit $STATUS fi -GSIZE=$(find $OUTFILE -printf "%s") +trap verifyint SIGTERM SIGINT + +rm -f $PIPE -CR=$(echo "scale=5; $SIZE/$GSIZE" | bc) -SPACESAVING=$(echo "scale=5; 100-$GSIZE/$SIZE*100" | bc) -printf "Compression Ratio: %.1f (%.1f %%)\n" $CR $SPACESAVING +GSIZE=$(find $OUTFILE -printf "%s") +if [ $SIZE -gt 0 ] ; then + CR=$(echo "scale=5; $SIZE/$GSIZE" | bc) + SPACESAVING=$(echo "scale=5; 100-$GSIZE/$SIZE*100" | bc) + printf "Compression Ratio: %.1f (%.1f %%)\n" $CR $SPACESAVING +fi -echo "Verifying $OUTFILE" +echo "Verifying $OUTFILE (hit CTRL-C to skip)" cat $OUTFILE | /usr/bin/pv -i 0.1 -s $GSIZE | md5sum --status -c $OUTFILE.md5sum STATUS=$? if [ $STATUS != 0 ] ; then echo "Verify FAILED" - test -f $OUTFILE && rm -f $OUTFILE - rm -f $OUTFILE.md5sum $PIPE - exit $STATUS + errorexit $STATUS fi cat $OUTFILE.md5sum | sed -e s/-/$BASENAME/ > $OUTFILE.md5sum -rm -f $PIPE exit 0