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