]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/differential-test
fix bad script tests + add smtp_host + fix tape options
[bacula/bacula] / regress / tests / differential-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory then create some           
4 #   new files, do a differential and restore those two files.
5 #
6 debug=0
7 if test "$debug" -eq 1 ; then
8   out="tee"
9 else
10   out="output"
11 fi
12
13 cwd=`pwd`
14 scripts/copy-test-confs
15 scripts/cleanup
16 echo "${cwd}/tmp/build" >/tmp/file-list
17 mkdir ${cwd}/tmp/build
18 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
19 cd ${cwd}/tmp
20 echo "${cwd}/tmp/build/ficheriro1.txt" >restore-list
21 echo "${cwd}/tmp/build/ficheriro2.txt" >>restore-list
22 cd ${cwd}
23
24 echo " "
25 echo " "
26 echo " === Starting differential-test at `date +%R:%S` ==="
27 echo " === Starting differential-test at `date +%R:%S` ===" >>working/log
28 echo " "
29
30 cat <<END_OF_DATA >tmp/bconcmds
31 @$out /dev/null
32 messages
33 @$out tmp/log1.out
34 label storage=File volume=TestVolume002
35 label storage=File volume=TestVolume001
36 run job=CompressedTest yes
37 wait
38 messages
39 quit
40 END_OF_DATA
41
42 if test "$debug" -eq 1 ; then
43   bin/bacula start
44   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
45 else
46   bin/bacula start 2>&1 >/dev/null
47   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
48 fi
49
50 scripts/check_for_zombie_jobs storage=File
51 echo "ficheriro1.txt" >${cwd}/tmp/build/ficheriro1.txt
52 echo "ficheriro2.txt" >${cwd}/tmp/build/ficheriro2.txt
53
54 cat <<END_OF_DATA >tmp/bconcmds
55 @$out /dev/null
56 messages
57 @$out tmp/log1.out
58 @# Force differential on the second Volume
59 update volume=TestVolume002 VolStatus=Used
60 run level=differential job=CompressedTest yes
61 wait
62 messages
63 @$out
64 END_OF_DATA
65
66 if test "$debug" -eq 1 ; then
67   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
68 else
69   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
70 fi
71
72 scripts/check_for_zombie_jobs storage=File
73 echo "ficheriro2.txt" >${cwd}/tmp/build/ficheriro2.txt
74
75 cat <<END_OF_DATA >tmp/bconcmds
76 @$out /dev/null
77 messages
78 @$out tmp/log1.out
79 run level=incremental job=CompressedTest yes
80 wait
81 messages
82 @# 
83 @# now do a restore
84 @#
85 @$out tmp/log2.out
86 restore where=${cwd}/tmp/bacula-restores storage=File file=<${cwd}/tmp/restore-list
87 yes
88 wait
89 messages
90 @$out
91 quit
92 END_OF_DATA
93
94 if test "$debug" -eq 1 ; then
95   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
96 else
97   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
98 fi
99
100 scripts/check_for_zombie_jobs storage=File
101 bin/bacula stop 2>&1 >/dev/null
102 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
103 bstat=$?
104 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
105 rstat=$?
106 #
107 # Delete .c files because we will only restore the txt files
108 #
109 rm -f tmp/build/*.c
110 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
111 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
112    echo " "
113    echo " "
114    echo "  !!!!! differential-test Bacula source failed!!! !!!!! "
115    echo "  !!!!! differential-test failed!!! !!!!! " >>test.out
116    if [ $bstat != 0 -o $rstat != 0 ] ; then
117       echo "  !!!!! Bad Job termination status     !!!!! "
118       echo "  !!!!! Bad Job termination status     !!!!! " >>test.out
119    else
120       echo "  !!!!! Restored files differ          !!!!! "
121       echo "  !!!!! Restored files differ          !!!!! " >>test.out
122    fi
123    echo " "
124 else
125    echo "  ===== differential-test Bacula source OK ===== "
126    echo "  ===== differential-test OK ===== " >>test.out
127    scripts/cleanup
128 fi