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