]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/bscan-tape
797444a5e36efe119e697f34f173392bab5ce8f4
[bacula/bacula] / regress / tests / bscan-tape
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 # Run a simple backup of the Bacula build directory using the compressed option
9 #   then backup four times, each with incremental then 
10 #   do a bscan and restore.
11 #   It should require at least 4 different bsrs.
12 #
13 TestName="bscan-tape"
14 JobName=bscantape
15 . scripts/functions
16
17 require_tape_drive
18
19 copy_tape_confs
20
21 echo "${cwd}/build" >tmp/file-list
22
23 cp ${cwd}/bin/bacula-sd.conf tmp/1
24 sed "s%# Maximum File Size%  Maximum File Size%" tmp/1 >${cwd}/bin/bacula-sd.conf
25
26 change_jobname NightlySave $JobName
27 start_test
28
29 cat <<END_OF_DATA >tmp/bconcmds
30 @$out /dev/null
31 estimate job=$JobName listing
32 estimate job=$JobName listing
33 messages
34 @$out tmp/log1.out
35 setdebug level=2 storage=tape
36 label storage=tape volume=TestVolume001 slot=0 pool=Default
37 run job=$JobName level=Full yes 
38 wait
39 run job=$JobName level=Full yes
40 wait
41 messages
42 quit
43 END_OF_DATA
44
45 run_bacula
46 check_for_zombie_jobs storage=tape
47
48 echo "Backup 1 done"
49 # make some files for the incremental to pick up
50 touch ${cwd}/build/src/dird/*.c ${cwd}/build/src/dird/*.o
51 touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
52    
53 #
54 # run a second job
55 #
56 cat <<END_OF_DATA >tmp/bconcmds
57 @$out /dev/null
58 messages
59 @$out tmp/log1.out
60 run job=$JobName level=Incremental yes
61 wait
62 messages
63 quit
64 END_OF_DATA
65
66 run_bconsole
67 scripts/check_for_zombie_jobs storage=tape
68
69 echo "Backup 2 done"
70 touch ${cwd}/build/src/dird/*.c
71 touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
72 #
73 # run a third job
74 #
75
76 run_bconsole
77 scripts/check_for_zombie_jobs storage=tape
78
79 echo "Backup 3 done"
80 # make some files for the incremental to pick up
81 touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
82 #echo "abc" > ${cwd}/build/src/lib/dummy
83 #
84 # run a fourth job
85 #
86
87 run_bconsole
88 scripts/check_for_zombie_jobs storage=tape
89
90 stop_bacula
91
92 echo "Backup 4 done"
93 #
94 # now drop and recreate the database
95 #
96 cd bin
97 ./drop_bacula_tables >/dev/null 2>&1
98 ./make_bacula_tables >/dev/null 2>&1
99 ./grant_bacula_privileges 2>&1 >/dev/null
100 cd ..
101
102 echo "volume=TestVolume001" >tmp/bscan.bsr
103
104 bscan_libdbi
105
106 # If the database has a password pass it to bscan
107 if test "x${db_password}" = "x"; then
108   PASSWD=
109 else
110   PASSWD="-P ${db_password}"
111 fi
112
113 if test "$debug" -eq 1 ; then
114   $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf tape                
115 else
116   $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf tape >/dev/null 2>&1
117 fi
118
119 echo $BSCANLIBDBI
120
121 cat <<END_OF_DATA >tmp/bconcmds
122 @$out /dev/null
123 messages
124 @$out tmp/log2.out
125 @# 
126 @# now do a restore
127 @#
128 restore where=${cwd}/tmp/bacula-restores select all storage=tape done
129 yes
130 wait
131 messages
132 quit
133 END_OF_DATA
134
135 run_bacula
136 check_for_zombie_jobs storage=tape
137 stop_bacula
138 rm -f  ${cwd}/build/src/lib/dummy
139
140 check_two_logs
141 check_restore_diff
142 end_test