1 |
--- smeserver-affa-0.9.0/root/sbin/e-smith/affa.createBackupFileOption2 2008-03-08 18:00:25.000000000 +0100 |
2 |
+++ smeserver-affa-0.9.0/root/sbin/e-smith/affa 2008-03-08 18:00:25.000000000 +0100 |
3 |
@@ -2500,12 +2500,7 @@ |
4 |
$restore_list.="$f "; |
5 |
} |
6 |
close(DIR); |
7 |
- my @cmd=('/bin/tar', '-C', "$job{'RootDir'}/$jobname/$archive/", '-cf - ', $restore_list, |
8 |
- '|', '/usr/bin/pv -i 0.3', "-s $size", |
9 |
- '|', '/bin/gzip', |
10 |
- "> $outfile" |
11 |
- ); |
12 |
- my $status=ExecCmd( @cmd, 0 ); |
13 |
+ my $status=system("/usr/lib/affa/create-backup-file.sh $job{'RootDir'} $jobname $archive '$restore_list' $outfile $size"); |
14 |
if( $status!=0 ) |
15 |
{ |
16 |
unlink( $outfile ); |
17 |
--- smeserver-affa-0.9.0/root/usr/lib/affa/create-backup-file.sh.createBackupFileOption2 2008-03-08 18:02:00.000000000 +0100 |
18 |
+++ smeserver-affa-0.9.0/root/usr/lib/affa/create-backup-file.sh 2008-03-08 18:01:29.000000000 +0100 |
19 |
@@ -0,0 +1,49 @@ |
20 |
+#!/bin/bash |
21 |
+ |
22 |
+# This script is part of the Affa package |
23 |
+# Michael Weinberger 2008 |
24 |
+ |
25 |
+export PATH=/bin:/usr/bin |
26 |
+set -o pipefail |
27 |
+ |
28 |
+ROOTDIR=$1 |
29 |
+JOB=$2 |
30 |
+ARCHIVE=$3 |
31 |
+RESTORE=$4 |
32 |
+OUTFILE=$5 |
33 |
+BASENAME=`basename $OUTFILE` |
34 |
+SIZE=$6 |
35 |
+ |
36 |
+PIPE=/tmp/affa.$$.$(date +%s) |
37 |
+mkfifo $PIPE |
38 |
+ |
39 |
+echo "Writing $OUTFILE" |
40 |
+(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 |
41 |
+ |
42 |
+STATUS=$? |
43 |
+if [ $STATUS != 0 ] ; then |
44 |
+ test -f $OUTFILE && rm -f $OUTFILE |
45 |
+ rm -f $OUTFILE.md5sum $PIPE |
46 |
+ exit $STATUS |
47 |
+fi |
48 |
+ |
49 |
+GSIZE=$(find $OUTFILE -printf "%s") |
50 |
+ |
51 |
+CR=$(echo "scale=5; $SIZE/$GSIZE" | bc) |
52 |
+SPACESAVING=$(echo "scale=5; 100-$GSIZE/$SIZE*100" | bc) |
53 |
+printf "Compression Ratio: %.1f (%.1f %%)\n" $CR $SPACESAVING |
54 |
+ |
55 |
+echo "Verifying $OUTFILE" |
56 |
+cat $OUTFILE | /usr/bin/pv -i 0.1 -s $GSIZE | md5sum --status -c $OUTFILE.md5sum |
57 |
+STATUS=$? |
58 |
+if [ $STATUS != 0 ] ; then |
59 |
+ echo "Verify FAILED" |
60 |
+ test -f $OUTFILE && rm -f $OUTFILE |
61 |
+ rm -f $OUTFILE.md5sum $PIPE |
62 |
+ exit $STATUS |
63 |
+fi |
64 |
+ |
65 |
+cat $OUTFILE.md5sum | sed -e s/-/$BASENAME/ > $OUTFILE.md5sum |
66 |
+ |
67 |
+rm -f $PIPE |
68 |
+exit 0 |