]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/copy-volume-test
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / regress / tests / copy-volume-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 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 @#setdebug level=100 Dir
45 label storage=File volume=FileVolume001 Pool=Default
46 label storage=File volume=FileVolume002 Pool=Scratch
47 update Volume=FileVolume001 MaxVolBytes=3000000 pool=Default
48 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0
49 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0
50 @# 
51 run job=$JobName yes
52 wait
53 run job=$JobName yes
54 wait
55 update volume=FileVolume001 VolStatus=Used
56 update volume=FileVolume002 VolStatus=Used
57 @#list volumes
58 @#list jobs
59 messages
60 @$out ${cwd}/tmp/log11.out
61 @############################################################
62 @# should copy one job, and the second is empty
63 @############################################################
64 @# setdebug level=11 dir
65 @echo "Run copy-volume Job"
66 @#setdebug level=100 dir
67 run job=copy-volume yes
68 @sleep 5 
69 list jobs
70 llist jobid=1
71 llist jobid=2
72 llist jobid=3
73 llist jobid=4
74 llist jobid=5
75 status storage=DiskChanger
76 wait
77 list volumes
78 list jobs
79 llist jobid=1
80 llist jobid=2
81 llist jobid=3
82 llist jobid=4
83 llist jobid=5
84 sql
85 select * from JobMedia where JobId=1;
86
87 messages
88 @$out ${cwd}/tmp/log2.out
89 @############################################################
90 @# now do a restore
91 @# Expect: 
92 @#  Check that copy uses JobId 1,2
93 @#  Use File instead of DiskChanger
94 @#  Files are there        
95 @############################################################
96 @# Note, here we are restoring from the original backup,
97 @#  so if you specify storage=DiskChanger the restore will fail
98 restore where=${cwd}/tmp/bacula-restores select
99 unmark *
100 mark *
101 done
102 yes
103 wait
104 messages
105 quit
106 END_OF_DATA
107
108 run_bacula
109 check_for_zombie_jobs storage=File
110 check_restore_diff
111
112 # cleanup previous restore
113 rm -rf ${cwd}/tmp/bacula-restores
114
115 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
116 @############################################################
117 @# Purge File backup, and restore again
118 @# Expect:
119 @#  Check that copy uses other JobId
120 @#  Use DiskChanger
121 @#  Files are there
122 @############################################################
123 @$out ${cwd}/tmp/log3.out
124 setdebug level=50 storage=DiskChanger
125 purge volume=FileVolume001 yes
126 purge volume=FileVolume002 yes
127 @# Note, here we are restoring from the original backup,
128 @#  so if you specify storage=DiskChanger the restore will fail
129 restore where=${cwd}/tmp/bacula-restores select
130 unmark *
131 mark *
132 done
133 yes
134 wait
135 messages
136 quit
137 END_OF_DATA
138
139 run_bconsole
140
141 check_for_zombie_jobs storage=DiskChanger
142 check_restore_diff
143
144 # cleanup previous restore
145 rm -rf ${cwd}/tmp/bacula-restores
146 touch ${cwd}/build/po/test.po
147
148 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
149 @############################################################
150 @# Run a new Incremental, restore melting Copy and Backup
151 @# and copy the new job to Changer
152 @# Expect:
153 @#  Files are there
154 @#  Copy OK
155 @############################################################
156 @$out ${cwd}/tmp/log4.out
157 run job=$JobName yes
158 wait
159 messages
160 setdebug level=50 storage=DiskChanger
161 restore where=${cwd}/tmp/bacula-restores select all
162 done
163 yes
164 wait
165 messages
166 update volume=FileVolume001 VolStatus=Used
167 update volume=FileVolume002 VolStatus=Used
168 run job=copy-volume yes
169 wait
170 messages
171 quit
172 END_OF_DATA
173
174 run_bconsole
175
176 check_for_zombie_jobs storage=DiskChanger
177 check_restore_diff
178
179 stop_bacula
180
181 get_mig_info 1 ${cwd}/tmp/log11.out
182
183 if [ -z "$RET" -o "$RET" = 0 ]; then
184     bstat=2
185     print_debug "The first job must have been copied"
186 fi
187
188 get_mig_info 2 ${cwd}/tmp/log11.out
189
190 if [ -n "$RET" ]; then
191     bstat=2
192     print_debug "The second job has no files, it can't have been copied"
193 fi
194
195 JOBID=`awk -F= '/Job queued. JobId/ {if(!f){print $2; f=1;}}' ${cwd}/tmp/log4.out`
196 get_mig_info $JOBID ${cwd}/tmp/log4.out
197
198 if [ -z "$RET" -o "$RET" = 0 ]; then
199     bstat=2
200     print_debug "The new incremental job must have been copied"
201 fi
202
203 check_two_logs
204 end_test