]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restore-disk-seek-test
Add new file
[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 cwd=`pwd`
10 scripts/copy-test-confs
11 scripts/cleanup
12 echo "${cwd}/tmp/build" >/tmp/file-list
13 rm -rf ${cwd}/tmp/build
14 mkdir ${cwd}/tmp/build
15 # Copy only the .c files (to be restored)
16 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
17 cd ${cwd}/tmp/build
18 ls >../1
19 cd ..
20 sed s%\^%${cwd}/tmp/build/% 1 >restore-list
21 # At this point restore-list contains the list
22 #  of files we will restore
23 rm -f 1
24 cd ${cwd}
25 # Now backup *everything* 
26 rm -rf  ${cwd}/tmp/build
27 mkdir ${cwd}/tmp/build
28 cp -fp ${cwd}/build/src/dird/* ${cwd}/tmp/build
29 bin/bacula stop  2>&1 >/dev/null
30 cd bin
31 ./drop_bacula_tables >/dev/null 2>&1
32 ./make_bacula_tables >/dev/null 2>&1
33 ./grant_bacula_privileges 2>&1 >/dev/null
34 cd ..
35 # Enable MaximumFileSize
36 cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
37 sed "s%# Maximum File Size%  Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
38
39 echo " "
40 echo " "
41 echo " === Starting restore-disk-seek-test ==="
42 echo " === Starting restore-disk-seek-test ===" >>working/log
43 echo " "
44
45 # bin/bacula start -v -v 2>&1 >/dev/null
46 bin/bacula start -v -v 
47 bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
48 @tee /dev/null
49 messages
50 @tee tmp/log1.out
51 label storage=File volume=TestVolume001
52 run job=CompressedTest yes
53 wait
54 messages
55 @# 
56 @# now do a restore
57 @#
58 @tee tmp/log2.out
59 sql
60 select * from JobMedia;
61
62 restore where=${cwd}/tmp/bacula-restores storage=File
63 7
64 <${cwd}/tmp/restore-list
65
66 yes
67 wait
68 messages
69 @tee
70 quit
71 END_OF_DATA
72 bin/bacula stop 2>&1 >/dev/null
73 # Now setup a control directory of only what we *should* restore
74 rm -rf ${cwd}/tmp/build
75 mkdir  ${cwd}/tmp/build
76 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
77 grep "^Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
78 bstat=$?
79 grep "^Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
80 rstat=$?
81 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
82 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
83    echo " "
84    echo " "
85    echo "  !!!!! restore-disk-seek-test Bacula source failed!!! !!!!! "
86    echo "  !!!!! restore-disk-seek-test failed!!! !!!!! " >>test.out
87    echo " "
88 else
89    echo "  ===== restore-disk-seek-test Bacula source OK ===== "
90    echo "  ===== restore-disk-seek-test OK ===== " >>test.out
91 #  scripts/cleanup
92 #  rm -rf ${cwd}/tmp/build
93 fi