]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/copy-upgrade-test
Fix typo in maxtime-test
[bacula/bacula] / regress / tests / copy-upgrade-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory then copy it
4 #   to another device. We test that when the original job is purged
5 #   the next copy is "upgraded" to Type=B
6 #
7 # This script uses the virtual disk autochanger
8 #
9 TestName="copy-upgrade-test"
10 JobName=CopyJobSave
11 . scripts/functions
12
13
14 scripts/cleanup
15 scripts/copy-migration-confs
16 scripts/prepare-disk-changer
17 echo "${cwd}/build" >${cwd}/tmp/file-list
18 sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
19 sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
20
21
22 change_jobname NightlySave $JobName
23 start_test
24
25 #
26 # Note, we first backup into Pool Default, 
27 #          then Copy into Pool Full. 
28 #              Pool Default uses Storage=File
29 #              Pool Full    uses Storage=DiskChanger
30
31 # Write out bconsole commands
32 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
33 @$out /dev/null
34 messages
35 @$out ${cwd}/tmp/log1.out
36 @# setdebug level=100 storage=File
37 label storage=File volume=FileVolume001 Pool=Default
38 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
39 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
40 run job=$JobName yes
41 wait
42 messages
43 END_OF_DATA
44
45 run_bacula
46
47 echo test > ${cwd}/build/po/test
48
49 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
50 @$out ${cwd}/tmp/log1.out
51 run job=$JobName level=incremental yes
52 wait
53 messages
54 END_OF_DATA
55
56 run_bconsole
57
58 echo test1 > ${cwd}/build/po/test1
59
60 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
61 @$out ${cwd}/tmp/log1.out
62 run job=$JobName level=incremental yes
63 wait
64 messages
65 @# we should be able to purge jobid 1 3 times
66 update volume=FileVolume001 VolStatus=Used
67 @# 4,5
68 run job=copy-job jobid=1 yes
69 wait
70 @# 6,7
71 run job=copy-job jobid=2 yes
72 wait
73 @# 8,9
74 run job=copy-job jobid=3 yes
75 wait
76 @# 10,11
77 run job=copy-job jobid=1 yes
78 wait
79 @# 12,13
80 run job=copy-job jobid=2 yes
81 wait
82 @# 14,15
83 run job=copy-job jobid=3 yes
84 wait
85 @# 16,17
86 run job=copy-job jobid=1 yes
87 wait
88 @# 18,19
89 run job=copy-job jobid=1 yes
90 wait
91 messages
92 list jobs
93 list volumes
94 END_OF_DATA
95
96 run_bconsole
97
98 cat<<END_OF_DATA > ${cwd}/tmp/bconcmds.resto
99 @# 
100 @# now do a restore
101 @#
102 @$out ${cwd}/tmp/log2.out
103 list volumes 
104 restore copies where=${cwd}/tmp/bacula-restores select storage=DiskChanger
105 unmark *
106 mark *
107 done
108 yes
109 list volumes
110 wait
111 messages
112 quit
113 END_OF_DATA
114
115 run_bconsole ${cwd}/tmp/bconcmds.resto
116 check_two_logs
117 check_restore_diff
118
119 cat <<EOF >${cwd}/tmp/bconcmds
120 @$out ${cwd}/tmp/log2.out
121 @# the last restore
122 @# should restore with 1,2,3
123 delete jobid=1
124 @# should restore with 5,2,3
125 EOF
126 run_bconsole
127
128 rm -rf ${cwd}/tmp/bacula-restores
129 run_bconsole ${cwd}/tmp/bconcmds.resto
130 check_two_logs
131 check_restore_diff
132
133 # remove first copy of job=1
134 cat <<EOF >${cwd}/tmp/bconcmds
135 @$out ${cwd}/tmp/log2.out
136 delete jobid=5
137 @# should restore with 11,2,3
138 EOF
139 run_bconsole
140
141 rm -rf ${cwd}/tmp/bacula-restores
142 run_bconsole ${cwd}/tmp/bconcmds.resto
143 check_two_logs
144 check_restore_diff
145
146 # remove 2 copies at the same time
147 cat <<EOF >${cwd}/tmp/bconcmds
148 @$out ${cwd}/tmp/log2.out
149 delete jobid=11,17
150 @# should restore with 19,2,3
151 EOF
152 run_bconsole
153
154 rm -rf ${cwd}/tmp/bacula-restores
155 run_bconsole ${cwd}/tmp/bconcmds.resto
156 check_two_logs
157 check_restore_diff
158
159 # remove job and copies of jobid=3
160 cat <<EOF >${cwd}/tmp/bconcmds
161 @$out ${cwd}/tmp/log2.out
162 delete jobid=3,9,15
163 @# should restore with 19,2
164 EOF
165 run_bconsole
166
167 rm -f ${cwd}/build/po/test1
168 rm -rf ${cwd}/tmp/bacula-restores
169 run_bconsole ${cwd}/tmp/bconcmds.resto
170 check_two_logs
171 check_restore_diff
172
173 awk '/You have selected the following JobIds:/ { print $7 }' \
174       ${cwd}/tmp/log2.out > ${cwd}/tmp/real
175 awk '/should restore with/ { print $5 }' \
176       ${cwd}/tmp/log2.out > ${cwd}/tmp/should
177
178 diff -u ${cwd}/tmp/real ${cwd}/tmp/should
179 if [ $? -ne 0 ]; then
180     print_debug "Bad job selection!!!"
181     rstat=2
182 fi
183
184 check_for_zombie_jobs storage=File
185 stop_bacula
186 end_test