]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/2drive-incremental-2disk
commit changes
[bacula/bacula] / regress / tests / 2drive-incremental-2disk
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory then create some           
4 #   new files, do an Incremental and restore those two files.
5 #
6 # This script uses the virtual disk autochanger and two drives
7 #
8 . config.out
9 debug=0
10 if test "$debug" -eq 1 ; then
11   out="tee"
12 else
13   out="output"
14 fi
15 cwd=`pwd`
16 bin/bacula stop  2>&1 >/dev/null
17 cd bin
18 ./drop_bacula_tables >/dev/null 2>&1
19 ./make_bacula_tables >/dev/null 2>&1
20 ./grant_bacula_privileges 2>&1 >/dev/null
21 cd ..
22
23 scripts/copy-2disk-drive-confs
24 scripts/prepare-two-disks
25 echo "${cwd}/tmp/build" >/tmp/file-list
26 if test ! -d ${cwd}/tmp/build ; then
27    mkdir ${cwd}/tmp/build
28 fi
29 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
30 cd ${cwd}/tmp
31 echo "${cwd}/tmp/build/ficheriro1.txt" >restore-list
32 echo "${cwd}/tmp/build/ficheriro2.txt" >>restore-list
33 cd ${cwd}
34
35 # Turn off Prefer Mounted Volumes so we use 2 drives
36 outf="tmp/sed_tmp"
37 echo "s%# Prefer Mounted Volumes%  Prefer Mounted Volumes%g" >${outf}
38 cp ${cwd}/bin/bacula-dir.conf ${cwd}/tmp/1
39 # Comment the next line out to write everything to one drive
40 #  otherwise, it writes the two jobs to different drives
41 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
42
43 echo " "
44 echo " "
45 echo " === Starting 2drive-incremental-2disk test ==="
46 echo " === Starting 2drive-incremental-2disk test ===" >>working/log
47 echo " "
48
49 # Write out bconsole commands
50 cat <<END_OF_DATA >tmp/bconcmds
51 @output /dev/null
52 messages
53 @$out tmp/log1.out
54 label storage=DDS-4 volume=TestVolume001 slot=1 Pool=Default drive=0
55 label storage=DDS-4 volume=TestVolume002 slot=2 Pool=Default drive=1
56 @#setdebug level=100 storage=DDS-4
57 run job=NightlySave yes
58 run job=NightlySave yes
59 run job=NightlySave yes
60 run job=NightlySave yes
61 run job=NightlySave yes
62 @sleep 3
63 status storage=DDS-4
64 wait
65 list volumes
66 list jobs
67 status storage=DDS-4
68 messages
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 echo "ficheriro1.txt" >${cwd}/tmp/build/ficheriro1.txt
80 echo "ficheriro2.txt" >${cwd}/tmp/build/ficheriro2.txt
81
82 cat <<END_OF_DATA >tmp/bconcmds
83 @$out /dev/null
84 messages
85 @$out tmp/log1.out
86 @# Force Incremental on the second Volume
87 update volume=TestVolume001 VolStatus=Used
88 status storage=DDS-4
89 @#setdebug level=400 storage=DDS-4
90 run level=Incremental job=NightlySave yes
91 wait
92 list volumes
93 status storage=DDS-4
94 messages
95 @# 
96 @# now do a restore
97 @#
98 @$out tmp/log2.out
99 restore where=${cwd}/tmp/bacula-restores 
100 7
101 <${cwd}/tmp/restore-list
102
103 yes
104 wait
105 messages
106 @$out
107 quit
108 END_OF_DATA
109 if test "$debug" -eq 1 ; then
110   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
111 else
112   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
113 fi
114
115 bin/bacula stop 2>&1 >/dev/null
116 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
117 bstat=$?
118 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
119 rstat=$?
120 #
121 # Delete .c files because we will only restored the txt files
122 #
123 rm -f tmp/build/*.c
124 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
125 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
126    echo " "
127    echo " "
128    echo "  !!!!! 2drive-incremental-2disk test Bacula source failed!!! !!!!! "
129    echo "  !!!!! 2drive-incremental-2disk test failed!!! !!!!! " >>test.out
130    echo " "
131 else
132    echo "  ===== 2drive-incremental-2disk test Bacula source OK ===== "
133    echo "  ===== 2drive-incremental-2disk test OK ===== " >>test.out
134    scripts/cleanup
135 fi