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