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