]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/sd-sd-test
Big backport from Enterprise
[bacula/bacula] / regress / tests / sd-sd-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # Test SD to SD copy/migration
7 #
8 TestName="sd-sd-test"
9 JobName=MigrationJobSave
10
11 # the procedure to test volumes is not working with 2 SD
12 REGRESS_CHECK_CORRUPTION=no
13 . scripts/functions
14
15
16 scripts/cleanup
17 scripts/copy-migration-confs
18 scripts/prepare-disk-changer
19 echo "${cwd}/build" >${cwd}/tmp/file-list
20
21 sed -e "s:$cwd/working:$cwd/working2:   " \
22     -e "s:$cwd/tmp:$cwd/tmp2:" $conf/bacula-sd.conf > $conf/bacula-sd2.conf
23
24 $bperl -e "add_attribute('$conf/bacula-sd2.conf', 'Name', 'sd2', 'Storage')"
25 $bperl -e "add_attribute('$conf/bacula-sd2.conf', 'SDPort', $BASEPORT + 10, 'Storage')"
26 $bperl -e "add_attribute('$conf/bacula-sd2.conf', 'Media Type', 'DiskChangerMedia2', 'Device', 'Drive-0')"
27 $bperl -e "add_attribute('$conf/bacula-sd2.conf', 'Media Type', 'File2', 'Device', 'FileStorage')"
28 if [ x$FORCE_DEDUP = xyes ]; then
29    DEDUP_FS_OPTION=${DEDUP_FS_OPTION:-bothsides}
30    $bperl -e 'add_attribute("$conf/bacula-sd2.conf", "Plugin Directory", "$plugins", "Storage")'
31    $bperl -e 'add_attribute("$conf/bacula-sd2.conf", "Device Type", "Dedup", "Device")'
32    $bperl -e 'add_attribute("$conf/bacula-sd2.conf", "DedupDirectory", "${working}2", "Storage")'
33    $bperl -e 'add_attribute("$conf/bacula-sd2.conf", "MaximumContainerSize", "50MB", "Storage")'
34 fi
35
36
37 rm -rf $cwd/working2 $cwd/tmp2
38 mkdir -p $cwd/working2 $cwd/tmp2
39 cp -r $tmp/disk-changer $cwd/tmp2
40
41 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'SDPort', $BASEPORT + 10, 'Storage', 'File')"
42 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'Media Type', 'File2', 'Storage', 'File')"
43
44 # Here, File is pointing to SD2 and DiskChanger is pointing to SD1
45
46 $bin/bacula-sd -c $conf/bacula-sd2.conf
47 sleep 1
48 pid=`cat $cwd/working2/bacula-sd.*.pid`
49 trap "kill $pid" INT
50
51
52 change_jobname NightlySave $JobName
53 start_test
54
55 #
56 # Note, we first backup into Pool Default, 
57 #          then Migrate into Pool Full. 
58 #              Pool Default uses Storage=File            (SD2)
59 #              Pool Full    uses Storage=DiskChanger     (SD1)
60
61 # Write out bconsole commands
62 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
63 @output /dev/null
64 messages
65 @$out ${cwd}/tmp/log1.out
66 label storage=File volume=FileVolume001 Pool=Default
67 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
68 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
69 @# run two jobs (both will be migrated)
70 run job=$JobName yes
71 run job=$JobName yes
72 wait
73 list jobs
74 list volumes
75 @#setdebug level=100 dir
76 @# should migrate two jobs
77 @#setdebug level=51 storage=DiskChanger
78 messages
79 st storage=File
80 st storage=DiskChanger
81 @# setdebug level=200 dir
82 @# setdebug level=200 storage=File
83 @# setdebug level=200 storage=DiskChanger
84 setdebug level=700 storage=File trace=1 flags=dedup,asx,dde
85 setdebug level=700 storage=DiskChanger trace=1 flags=dedup,asx,dde
86 run job=migrate-job yes
87 @sleep 10
88 messages
89 wait
90 messages
91 @# purge volume=FileVolume001
92 list jobs 
93 list volumes
94 list joblog jobid=6
95 wait
96 @#
97 @# Now do another backup, but level Incremental
98 @#
99 run job=$JobName level=Incremental yes
100 wait
101 messages
102 @#
103 @# This final job that runs should be Incremental and
104 @# not upgraded to full.
105 list jobs
106 @# 
107 @# now do a restore
108 @#
109 @$out ${cwd}/tmp/log2.out
110 list volumes 
111 restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
112 unmark *
113 mark *
114 done
115 yes
116 list volumes
117 wait
118 messages
119 quit
120 END_OF_DATA
121
122 run_bacula
123 check_for_zombie_jobs storage=File
124 stop_bacula
125
126 check_two_logs
127 check_restore_diff
128
129 trap - INT
130
131 PID=`cat $cwd/working2/bacula-sd.*.pid`
132 if [ "$PID" != "" ]; then
133     kill $PID >/dev/null 2>/dev/null
134 fi
135
136 end_test