]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/multi2-storage-test
Tweak multi2-storage-test again
[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 (/SDPort = /) { $_ =~ s/(\d+)/1810$i/}
17   if (/Name = .+?-sd/) { $_ =~ s/-sd/-sd$i/}
18   if (/WorkingDirectory/) { $_ =~ s:working:tmp/$i:}
19   if (/Pid Directory/) { $_ =~ s:working:tmp/$i:}
20   if (/(Archive|Changer) Device/) { $_ =~ s:$tmp:$tmp/$i:}
21   print;
22   ' $conf/bacula-sd.conf > $conf/bacula-sd$i.conf
23   mkdir -p ${working}$i
24   sed "s/bacula-sd.conf/bacula-sd${i}.conf/" $scripts/bacula-ctl-sd \
25       > $tmp/bacula-ctl-sd$i
26   chmod +x $tmp/bacula-ctl-sd$i
27   mkdir -p $tmp/$i
28 done
29
30 # Patch up bacula-dir.conf
31 perl -ne '
32 if (/^Storage {/) { $in=1; $nb++; }
33 if (/^}/) { $in=0 }
34 if (/SDPort = (\d+)/ && $in) {if ($nb == 2) { $_ = "  SDPort = 18102\n"; }}
35 if (/SDPort = (\d+)/ && $in) {if ($nb == 3) { $_ = "  SDPort = 18103\n"; }}
36 if (/SDPort = (\d+)/ && $in) {if ($nb == 4) { $_ = "  SDPort = 18104\n"; }}
37 print;
38 ' $conf/bacula-dir.conf > $tmp/1
39 cp $tmp/1 $conf/bacula-dir.conf
40
41 disable_pluguins
42
43 echo "${cwd}/build" >${cwd}/tmp/file-list
44
45 change_jobname $JobName
46 start_test
47
48 # Write out bconsole commands
49 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
50 @out /dev/null
51 messages
52 @$out ${cwd}/tmp/log1.out
53 label storage=tape volume=TestVolume001 Pool=Default slot=1 drive=0
54 label storage=File  volume=TestVolume002 Pool=Default
55 run job=$JobName storage=tape yes
56 wait
57 messages
58 quit
59 END_OF_DATA
60
61 # Start SDs
62 for sd in 2 3 4; do
63   $tmp/bacula-ctl-sd$sd start &> /dev/null
64 done
65
66 run_bacula
67
68 echo "ficheriro1.txt" >${cwd}/build/po/ficheriro1.txt
69 echo "ficheriro2.txt" >${cwd}/build/po/ficheriro2.txt
70
71
72 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
73 @out /dev/null
74 messages
75 @$out ${cwd}/tmp/log1.out
76 @# Force Incremental on the second Volume
77 run level=Incremental storage=File job=$JobName yes
78 wait
79 messages
80 @# 
81 @# now do a restore
82 @#
83 @$out ${cwd}/tmp/log2.out
84 setdebug trace=1 level=110 client
85 setdebug trace=1 level=110 director
86 restore where=${cwd}/tmp/bacula-restores select all done yes
87 wait
88 messages
89 show storage
90 sql
91 select * FROM Storage;
92 select VolumeName, Name, StorageId, MediaType FROM Media JOIN Storage USING (StorageId);
93
94 quit
95 END_OF_DATA
96
97 run_bconsole
98
99 check_for_zombie_jobs storage=File
100 check_for_zombie_jobs storage=tape
101
102 stop_bacula
103 for sd in 2 3 4; do
104   $tmp/bacula-ctl-sd$sd stop &> /dev/null
105 done
106
107 check_two_logs
108 check_restore_diff
109
110 end_test