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