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