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