]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/multi2-storage-test
regress: Reproduce #1582 about multiple devices restore
[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 ${working}$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 # Start SDs
50 for sd in 2 3 4; do
51   $tmp/bacula-ctl-sd$sd stop &> /dev/null
52   $tmp/bacula-ctl-sd$sd start &> /dev/null
53 done
54
55
56 # Write out bconsole commands
57 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
58 @out /dev/null
59 messages
60 @$out ${cwd}/tmp/log1.out
61 label storage=tape volume=TestVolume001 Pool=Default slot=1 drive=0
62 label storage=File  volume=TestVolume002 Pool=Default
63 label storage=File2 volume=File2-Vol001 Pool=Default
64 label storage=File3 volume=File3-Vol001 Pool=Default
65 label storage=File4 volume=File4-Vol001 Pool=Default
66 run job=$JobName storage=tape yes
67 wait
68 messages
69 @exec "touch $cwd/build/po/fr.po"
70 run job=$JobName storage=File yes
71 wait
72 messages
73 @exec "touch $cwd/build/po/de.po"
74 run job=$JobName storage=File2 yes
75 wait
76 messages
77 @exec "touch $cwd/build/po/it.po"
78 run job=$JobName storage=File3 yes
79 wait
80 messages
81 @exec "touch $cwd/build/po/es.po"
82 run job=$JobName storage=File4 yes
83 wait
84 messages
85 quit
86 END_OF_DATA
87
88 run_bacula
89
90 echo "ficheriro1.txt" >${cwd}/build/po/ficheriro1.txt
91 echo "ficheriro2.txt" >${cwd}/build/po/ficheriro2.txt
92
93
94 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
95 @out /dev/null
96 messages
97 @$out ${cwd}/tmp/log1.out
98 @# Force Incremental on the second Volume
99 @exec "touch $cwd/build/po/fi.po"
100 run level=Incremental storage=File job=$JobName yes
101 wait
102 messages
103 @exec "touch $cwd/build/po/uk.po"
104 run level=Incremental storage=File2 job=$JobName yes
105 wait
106 messages
107 @exec "touch $cwd/build/po/sv.po"
108 run level=Incremental storage=File3 job=$JobName yes
109 wait
110 messages
111 @exec "touch $cwd/build/po/README"
112 run level=Incremental storage=File4 job=$JobName yes
113 wait
114 messages
115 @# 
116 @# now do a restore
117 @#
118 @$out ${cwd}/tmp/log2.out
119 setdebug trace=1 level=110 client
120 setdebug trace=1 level=110 director
121 restore where=${cwd}/tmp/bacula-restores select all done yes
122 wait
123 messages
124 @$out ${cwd}/tmp/status.out
125 status all
126 @exec "touch $cwd/build/po/POTFILES"
127 @$out ${cwd}/tmp/log1.out
128 run level=Incremental storage=File4 job=$JobName yes
129 wait
130 messages
131 show storage
132 sql
133 select * FROM Storage;
134 select VolumeName, Name, StorageId, MediaType FROM Media JOIN Storage USING (StorageId);
135
136 quit
137 END_OF_DATA
138
139 run_bconsole
140
141 check_for_zombie_jobs storage=File
142 check_for_zombie_jobs storage=tape
143
144 stop_bacula
145 for sd in 2 3 4; do
146   $tmp/bacula-ctl-sd$sd stop &> /dev/null
147 done
148
149 check_two_logs
150 check_restore_diff
151
152 end_test