]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restore-disk-seek-test
Final changes
[bacula/bacula] / regress / tests / restore-disk-seek-test
1 #!/bin/sh
2 #
3 # Run a backup of the full bacula build directory, but with the
4 #   Maximum File Size set. Then do a restore of a few files to kick in
5 #   disk seeking (not yet enabled), and ensure that the restored files
6 #   match. Even though disk seeking is not yet enabled, this is a good test,
7 #   and once it is enabled, this will test it.
8 #
9 debug=0
10 if test "$debug" -eq 1 ; then
11   out="tee"
12 else
13   out="output"
14 fi
15
16 cwd=`pwd`
17 scripts/copy-test-confs
18 scripts/cleanup
19 echo "${cwd}/tmp/build" >/tmp/file-list
20 rm -rf ${cwd}/tmp/build
21 mkdir ${cwd}/tmp/build
22 # Copy only the .c files (to be restored)
23 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
24 cd ${cwd}/tmp/build
25 ls >../1
26 cd ..
27 sed s%\^%${cwd}/tmp/build/% 1 >restore-list
28 # At this point restore-list contains the list
29 #  of files we will restore
30 rm -f 1
31 cd ${cwd}
32 # Now backup *everything* 
33 rm -rf  ${cwd}/tmp/build
34 mkdir ${cwd}/tmp/build
35 cp -fp ${cwd}/build/src/dird/* ${cwd}/tmp/build
36 # Enable MaximumFileSize
37 cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
38 sed "s%# Maximum File Size%  Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
39
40 echo " "
41 echo " "
42 echo " === Starting restore-disk-seek-test at `date +%R:%S` ==="
43 echo " === Starting restore-disk-seek-test at `date +%R:%S` ===" >>working/log
44 echo " "
45
46 cat <<END_OF_DATA >tmp/bconcmds
47 @$out /dev/null
48 messages
49 @$out tmp/log1.out
50 label storage=File volume=TestVolume001
51 run job=CompressedTest yes
52 wait
53 messages
54 @# 
55 @# now do a restore
56 @#
57 @$out tmp/log2.out
58 sql
59 select * from JobMedia;
60
61 restore bootstrap=${cwd}/tmp/kern.bsr where=${cwd}/tmp/bacula-restores storage=File
62 7
63 <${cwd}/tmp/restore-list
64
65 yes
66 wait
67 messages
68 @$out
69 quit
70 END_OF_DATA
71
72 if test "$debug" -eq 1 ; then
73   bin/bacula start
74   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
75 else
76   bin/bacula start 2>&1 >/dev/null
77   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
78 fi
79
80 scripts/check_for_zombie_jobs storage=File
81 bin/bacula stop 2>&1 >/dev/null
82 # Now setup a control directory of only what we *should* restore
83 rm -rf ${cwd}/tmp/build
84 mkdir  ${cwd}/tmp/build
85 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
86 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
87 bstat=$?
88 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
89 rstat=$?
90 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
91 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
92    echo " "
93    echo " "
94    echo "  !!!!! restore-disk-seek-test Bacula source failed!!! !!!!! "
95    echo "  !!!!! restore-disk-seek-test failed!!! !!!!! " >>test.out
96    if [ $bstat != 0 -o $rstat != 0 ] ; then
97       echo "  !!!!! Bad Job termination status     !!!!! "
98       echo "  !!!!! Bad Job termination status     !!!!! " >>test.out
99    else
100       echo "  !!!!! Restored files differ          !!!!! "
101       echo "  !!!!! Restored files differ          !!!!! " >>test.out
102    fi
103    echo " "
104 else
105    echo "  ===== restore-disk-seek-test Bacula source OK ===== "
106    echo "  ===== restore-disk-seek-test OK ===== " >>test.out
107 #  scripts/cleanup
108 #  rm -rf ${cwd}/tmp/build
109 fi