]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/copy-volume-test
Backport from Bacula Enterprise
[bacula/bacula] / regress / tests / copy-volume-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 # Run a backup of the Bacula build directory on two Volumes
9 #   then copy it to another device.             
10 #
11 # This script uses the virtual disk autochanger and migration scripts
12 #
13 TestName="copy-volume-test"
14 JobName=MigVolBackup
15 . scripts/functions
16
17
18 scripts/cleanup
19 scripts/copy-migration-confs
20 scripts/prepare-disk-changer
21 echo "${cwd}/build" >${cwd}/tmp/file-list
22 #cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
23 #sed "s%# Maximum File Size%  Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
24
25 change_jobname NightlySave $JobName
26 sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
27 sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
28 rm -f ${cwd}/build/po/test.po >/dev/null
29
30 start_test
31
32 #
33 # Note, we first backup into Pool Default, 
34 #          then Copy into Pool Full. 
35 #              Pool Default uses Storage=File
36 #              Pool Full    uses Storage=DiskChanger
37
38 # Write out bconsole commands
39 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
40 @output /dev/null
41 messages
42 @$out ${cwd}/tmp/log1.out
43 setdebug level=50 storage=DiskChanger
44 label storage=File volume=FileVolume001 Pool=Default
45 label storage=File volume=FileVolume002 Pool=Scratch
46 update Volume=FileVolume001 MaxVolBytes=3000000 pool=Default
47 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0
48 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0
49 @# 
50 run job=$JobName yes
51 wait
52 run job=$JobName yes
53 wait
54 update volume=FileVolume001 VolStatus=Used
55 update volume=FileVolume002 VolStatus=Used
56 @#list volumes
57 @#list jobs
58 messages
59 @$out ${cwd}/tmp/log11.out
60 @############################################################
61 @# should copy one job, and the second is empty
62 @############################################################
63 @# setdebug level=11 dir
64 @echo "Run copy-volume Job"
65 @#setdebug level=100 dir
66 run job=copy-volume yes
67 @sleep 5 
68 list jobs
69 llist jobid=1
70 llist jobid=2
71 llist jobid=3
72 llist jobid=4
73 llist jobid=5
74 status storage=DiskChanger
75 wait
76 list volumes
77 list jobs
78 llist jobid=1
79 llist jobid=2
80 llist jobid=3
81 llist jobid=4
82 llist jobid=5
83 sql
84 select * from JobMedia where JobId=1;
85
86 messages
87 @$out ${cwd}/tmp/log2.out
88 @############################################################
89 @# now do a restore
90 @# Expect: 
91 @#  Check that copy uses JobId 1,2
92 @#  Use File instead of DiskChanger
93 @#  Files are there        
94 @############################################################
95 @# Note, here we are restoring from the original backup,
96 @#  so if you specify storage=DiskChanger the restore will fail
97 restore where=${cwd}/tmp/bacula-restores select
98 unmark *
99 mark *
100 done
101 yes
102 wait
103 messages
104 quit
105 END_OF_DATA
106
107 run_bacula
108 check_for_zombie_jobs storage=File
109 check_restore_diff
110
111 # cleanup previous restore
112 rm -rf ${cwd}/tmp/bacula-restores
113
114 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
115 @############################################################
116 @# Purge File backup, and restore again
117 @# Expect:
118 @#  Check that copy uses other JobId
119 @#  Use DiskChanger
120 @#  Files are there
121 @############################################################
122 @$out ${cwd}/tmp/log3.out
123 setdebug level=50 storage=DiskChanger
124 purge volume=FileVolume001 yes
125 purge volume=FileVolume002 yes
126 @# Note, here we are restoring from the original backup,
127 @#  so if you specify storage=DiskChanger the restore will fail
128 restore where=${cwd}/tmp/bacula-restores select
129 unmark *
130 mark *
131 done
132 yes
133 wait
134 messages
135 quit
136 END_OF_DATA
137
138 run_bconsole
139
140 check_for_zombie_jobs storage=DiskChanger
141 check_restore_diff
142
143 # cleanup previous restore
144 rm -rf ${cwd}/tmp/bacula-restores
145 touch ${cwd}/build/po/test.po
146
147 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
148 @############################################################
149 @# Run a new Incremental, restore melting Copy and Backup
150 @# and copy the new job to Changer
151 @# Expect:
152 @#  Files are there
153 @#  Copy OK
154 @############################################################
155 @$out ${cwd}/tmp/log4.out
156 run job=$JobName yes
157 wait
158 messages
159 setdebug level=50 storage=DiskChanger
160 restore where=${cwd}/tmp/bacula-restores select all
161 done
162 yes
163 wait
164 messages
165 update volume=FileVolume001 VolStatus=Used
166 update volume=FileVolume002 VolStatus=Used
167 run job=copy-volume yes
168 wait
169 messages
170 quit
171 END_OF_DATA
172
173 run_bconsole
174
175 check_for_zombie_jobs storage=DiskChanger
176 check_restore_diff
177
178 stop_bacula
179
180 get_mig_info 1 ${cwd}/tmp/log11.out
181
182 if [ -z "$RET" -o "$RET" = 0 ]; then
183     bstat=2
184     print_debug "The first job must have been copied"
185 fi
186
187 get_mig_info 2 ${cwd}/tmp/log11.out
188
189 if [ -n "$RET" ]; then
190     bstat=2
191     print_debug "The second job has no files, it can't have been copied"
192 fi
193
194 JOBID=`awk -F= '/Job queued. JobId/ {if(!f){print $2; f=1;}}' ${cwd}/tmp/log4.out`
195 get_mig_info $JOBID ${cwd}/tmp/log4.out
196
197 if [ -z "$RET" -o "$RET" = 0 ]; then
198     bstat=2
199     print_debug "The new incremental job must have been copied"
200 fi
201
202 check_two_logs
203 end_test