]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/base-job-test
tweak regress test
[bacula/bacula] / regress / tests / base-job-test
1 #!/bin/sh
2 #
3 # Run a basejob backup of the Bacula build directory
4 #   then restore it.
5 #
6
7 TestName="base-job-test"
8 JobName=backup
9 . scripts/functions
10 $rscripts/cleanup
11
12 copy_test_confs
13 sed 's/backup_advance/base_backup/' $rscripts/bacula-dir.conf.accurate > $tmp/1
14 sed 's/Name = backup/Name = backup; Base = base_backup, backup/' $tmp/1 > $conf/bacula-dir.conf
15 sed s/all,/all,saved,/ $conf/bacula-fd.conf > tmp/1
16 cp tmp/1 $conf/bacula-fd.conf
17
18 change_jobname BackupClient1 $JobName
19
20 p() {
21     echo "##############################################" >> ${cwd}/tmp/log1.out
22     echo "$*" >> ${cwd}/tmp/log1.out
23     echo "##############################################" >> ${cwd}/tmp/log2.out
24     echo "$*" >> ${cwd}/tmp/log2.out
25 }
26
27 # cleanup
28 rm -rf ${cwd}/build/accurate.new
29 rm -rf ${cwd}/build/accurate
30
31
32 # add extra files
33 mkdir ${cwd}/build/accurate
34 mkdir ${cwd}/build/accurate/dirtest
35 echo "test test" > ${cwd}/build/accurate/dirtest/hello
36 echo "test test" > ${cwd}/build/accurate/xxx
37 echo "test test" > ${cwd}/build/accurate/yyy
38 echo "test test" > ${cwd}/build/accurate/zzz
39 echo "test test" > ${cwd}/build/accurate/zzzzzz
40 echo "test test" > ${cwd}/build/accurate/xxxxxx
41 echo "test test" > ${cwd}/build/accurate/yyyyyy
42 echo "test test" > ${cwd}/build/accurate/xxxxxxxxx
43 echo "test test" > ${cwd}/build/accurate/yyyyyyyyy
44 echo "test test" > ${cwd}/build/accurate/zzzzzzzzz
45 echo ${cwd}/build > ${cwd}/tmp/file-list
46
47 start_test
48
49 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
50 @output /dev/null
51 messages
52 label volume=TestVolume001 storage=File pool=Default
53 messages
54 END_OF_DATA
55
56 run_bacula
57
58 ################################################################
59 p Now do a second backup using base backup
60 ################################################################
61
62 echo ${cwd}/bin >> ${cwd}/tmp/file-list
63
64 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
65 @$out ${cwd}/tmp/log1.out
66 run job=base_backup level=base yes
67 wait
68 messages
69 update volume=TestVolume001 volstatus=Used
70 END_OF_DATA
71
72 run_bconsole
73
74 echo ${cwd}/build > ${cwd}/tmp/file-list
75
76 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
77 @$out ${cwd}/tmp/log4.out
78 label volume=TestVolume002 storage=File pool=Default
79 run job=backup level=full yes
80 wait
81 messages
82 @# 
83 @# now do a restore
84 @#
85 @$out ${cwd}/tmp/log2.out  
86 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
87 yes
88 wait
89 messages
90 END_OF_DATA
91
92
93 run_bconsole
94 check_for_zombie_jobs storage=File
95
96 check_two_logs
97 check_restore_diff
98
99 rm -rf ${cwd}/tmp/bacula-restores
100
101 ################################################################
102 p Now do a third backup after making few changes
103 ################################################################
104 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
105 @$out ${cwd}/tmp/log1.out
106 update volume=TestVolume002 volstatus=Used
107 label volume=TestVolume003 storage=File pool=Default
108 run job=backup level=incremental yes
109 wait
110 messages
111 @# 
112 @# now do a restore
113 @#
114 @$out ${cwd}/tmp/log2.out  
115 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
116 yes
117 wait
118 messages
119 END_OF_DATA
120
121 rm ${cwd}/build/accurate/yyyyyy  # delete a file
122 rm -rf ${cwd}/build/accurate/dirtest
123
124
125 run_bconsole
126 check_for_zombie_jobs storage=File
127
128 check_two_logs
129 check_restore_diff
130 check_files_written ${cwd}/tmp/log1.out 4
131
132 rm -rf ${cwd}/tmp/bacula-restores
133
134
135 ################################################################
136 p Test the job purge
137 ################################################################
138 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
139 @$out ${cwd}/tmp/log3.out
140 sql
141 SELECT count(*) FROM BaseFiles;
142
143 purge volume=TestVolume002
144 messages
145 sql
146 SELECT count(*) FROM BaseFiles;
147
148 END_OF_DATA
149
150 run_bconsole
151
152 grep -e ' 0 *|' ${cwd}/tmp/log3.out > /dev/null
153 if [ $? -ne 0 ]; then
154     print_debug "Can't purge the base job"
155     dstat=2
156 fi
157
158 grep -e 'FD Bytes Written: *0' ${cwd}/tmp/log4.out > /dev/null
159 if [ $? -ne 0 ]; then
160     print_debug "The first full job should have 0 byte in log4.out"
161     bstat=2
162 fi
163
164
165 stop_bacula
166 end_test