]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/multi2-storage-test
regress: test restore object in plugin-test
[bacula/bacula] / regress / tests / multi2-storage-test
1 #!/bin/sh
2 #
3 # This script uses the virtual disk autochanger
4 #
5 TestName="multi-storage-test"
6 JobName=backup
7 . scripts/functions
8
9 scripts/cleanup
10 scripts/copy-2disk-confs
11 scripts/prepare-disk-changer
12
13 # create a new bacula-sd.confs
14 for i in 2 3 4; do
15   perl -ne "\$i='$i';\$tmp='$tmp';"'
16   if (/Name =/ ) { $_ =~ s/-sd/-$i-sd/}
17   if (/SDPort = /) { $_ =~ s/(\d+)/1810$i/}
18   if (/mediatype = /) { $_ =~ s/FileMedia/FileMedia$i/}
19   if (/WorkingDirectory/) { $_ =~ s:working:tmp/$i:}
20   if (/Pid Directory/) { $_ =~ s:working:tmp/$i:}
21   if (/(Archive|Changer) Device/) { $_ =~ s:$tmp:$tmp/$i:}
22   print;
23   ' $conf/bacula-sd.conf > $conf/bacula-sd$i.conf
24   mkdir -p ${tmp}/$i
25   sed "s/bacula-sd.conf/bacula-sd${i}.conf/" $scripts/bacula-ctl-sd \
26       > $tmp/bacula-ctl-sd$i
27   chmod +x $tmp/bacula-ctl-sd$i
28   mkdir -p $tmp/$i
29 done
30
31 # Patch up bacula-dir.conf
32 perl -ne '
33 if (/^Storage {/) { $in=1; $nb++; }
34 if (/^}/) { $in=0 }
35 if (/SDPort = (\d+)/ && $in) {if ($nb == 2) { $_ = "  SDPort = 18102\n"; }}
36 if (/SDPort = (\d+)/ && $in) {if ($nb == 3) { $_ = "  SDPort = 18103\n"; }}
37 if (/SDPort = (\d+)/ && $in) {if ($nb == 4) { $_ = "  SDPort = 18104\n"; }}
38 print;
39 ' $conf/bacula-dir.conf > $tmp/1
40 cp $tmp/1 $conf/bacula-dir.conf
41
42 disable_pluguins
43
44 echo "${cwd}/build" >${cwd}/tmp/file-list
45
46 change_jobname $JobName
47 start_test
48
49 # Stop SDs
50 for sd in 2 3 4; do
51   $tmp/bacula-ctl-sd$sd stop &> /dev/null
52 done
53
54 sleep 2
55
56 # Start SDs
57 for sd in 2 3 4; do
58   $tmp/bacula-ctl-sd$sd start &> /dev/null
59 done
60
61 # Write out bconsole commands
62 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
63 @out /dev/null
64 messages
65 @$out ${cwd}/tmp/log1.out
66 label storage=tape volume=TestVolume001 Pool=Default slot=1 drive=0
67 label storage=File  volume=TestVolume002 Pool=Default
68 label storage=File2 volume=File2-Vol001 Pool=Default
69 label storage=File3 volume=File3-Vol001 Pool=Default
70 label storage=File4 volume=File4-Vol001 Pool=Default
71 run job=$JobName storage=tape yes
72 wait
73 messages
74 @exec "touch $cwd/build/po/fr.po"
75 run job=$JobName storage=File yes
76 wait
77 messages
78 @exec "touch $cwd/build/po/de.po"
79 run job=$JobName storage=File2 yes
80 wait
81 messages
82 @exec "touch $cwd/build/po/it.po"
83 run job=$JobName storage=File3 yes
84 wait
85 messages
86 @exec "touch $cwd/build/po/es.po"
87 run job=$JobName storage=File4 yes
88 wait
89 messages
90 quit
91 END_OF_DATA
92
93 run_bacula
94
95 echo "ficheriro1.txt" >${cwd}/build/po/ficheriro1.txt
96 echo "ficheriro2.txt" >${cwd}/build/po/ficheriro2.txt
97
98
99 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
100 @out /dev/null
101 messages
102 @$out ${cwd}/tmp/log1.out
103 @# Force Incremental on the second Volume
104 @exec "touch $cwd/build/po/fi.po"
105 run level=Incremental storage=File job=$JobName yes
106 wait
107 messages
108 @exec "touch $cwd/build/po/uk.po"
109 run level=Incremental storage=File2 job=$JobName yes
110 wait
111 messages
112 @exec "touch $cwd/build/po/sv.po $cwd/build/po/test.po"
113 run level=Incremental storage=File3 job=$JobName yes
114 wait
115 messages
116 @exec "touch $cwd/build/po/README"
117 run level=Incremental storage=File4 job=$JobName yes
118 wait
119 messages
120 @# 
121 @# now do a restore
122 @#
123 @$out ${cwd}/tmp/log22.out
124 setdebug trace=1 level=110 client
125 setdebug trace=1 level=110 director
126 restore where=${cwd}/tmp/bacula-restores select all done yes
127 wait
128 messages
129 @$out ${cwd}/tmp/status.out
130 status all
131 @exec "touch $cwd/build/po/POTFILES"
132 @$out ${cwd}/tmp/log1.out
133 run level=Incremental storage=File4 job=$JobName yes
134 wait
135 messages
136 @# run a job that will wait for a volume
137 @$out ${cwd}/tmp/log23.out
138 @exec "touch $cwd/build/po/ChangeLog"
139 run level=Incremental pool=Special storage=File3 job=$JobName yes
140 @sleep 5
141 messages
142 status dir
143 status storage=File3
144 @sleep 3
145 @# 
146 @# now do a restore with a backup that takes a drive
147 @#
148 setdebug trace=1 level=110 client
149 setdebug trace=1 level=110 director
150 restore where=${cwd}/tmp/bacula-restores select all done yes
151 @sleep 10
152 messages
153 status dir
154 label storage=File3 volume=test3 pool=Special
155 mount storage=File3
156 wait
157 messages
158 show storage
159 sql
160 select * FROM Storage;
161 select VolumeName, Name, StorageId, MediaType FROM Media JOIN Storage USING (StorageId);
162
163 quit
164 END_OF_DATA
165
166 run_bconsole
167
168 check_for_zombie_jobs storage=File
169 check_for_zombie_jobs storage=File2
170 check_for_zombie_jobs storage=File3
171 check_for_zombie_jobs storage=File4
172 check_for_zombie_jobs storage=tape
173
174 stop_bacula
175 for sd in 2 3 4; do
176   $tmp/bacula-ctl-sd$sd stop &> /dev/null
177 done
178
179 # we have two restore to test
180 cp $tmp/log22.out $tmp/log2.out
181 check_two_logs
182 cp $tmp/log23.out $tmp/log2.out
183 check_two_logs
184
185 check_restore_diff
186
187 end_test