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