]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/copy-volume-test
regress: Add test for bvfs-test with deleted files
[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 @$out /dev/null
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 quit
97 END_OF_DATA
98
99 run_bacula
100 check_for_zombie_jobs storage=File
101 check_restore_diff
102
103 # cleanup previous restore
104 rm -rf ${cwd}/tmp/bacula-restores
105
106 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
107 @############################################################
108 @# Purge File backup, and restore again
109 @# Expect:
110 @#  Check that copy uses other JobId
111 @#  Use DiskChanger
112 @#  Files are there
113 @############################################################
114 @$out ${cwd}/tmp/log3.out
115 purge volume=FileVolume001 yes
116 purge volume=FileVolume002 yes
117 restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
118 unmark *
119 mark *
120 done
121 yes
122 wait
123 messages
124 quit
125 END_OF_DATA
126
127 run_bconsole
128
129 check_for_zombie_jobs storage=DiskChanger
130 check_restore_diff
131
132 # cleanup previous restore
133 rm -rf ${cwd}/tmp/bacula-restores
134 touch ${cwd}/build/po/test.po
135
136 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
137 @############################################################
138 @# Run a new Incremental, restore melting Copy and Backup
139 @# and copy the new job to Changer
140 @# Expect:
141 @#  Files are there
142 @#  Copy OK
143 @############################################################
144 @$out ${cwd}/tmp/log4.out
145 run job=$JobName yes
146 wait
147 messages
148 restore where=${cwd}/tmp/bacula-restores select all
149 done
150 yes
151 wait
152 messages
153 update volume=FileVolume001 VolStatus=Used
154 update volume=FileVolume002 VolStatus=Used
155 run job=copy-volume yes
156 wait
157 messages
158 quit
159 END_OF_DATA
160
161 run_bconsole
162
163 check_for_zombie_jobs storage=DiskChanger
164 check_restore_diff
165
166 stop_bacula
167
168 get_mig_info 1 ${cwd}/tmp/log11.out
169
170 if [ -z "$RET" -o "$RET" = 0 ]; then
171     bstat=2
172     print_debug "The first job must have been copied"
173 fi
174
175 get_mig_info 2 ${cwd}/tmp/log11.out
176
177 if [ -n "$RET" ]; then
178     bstat=2
179     print_debug "The second job has no files, it can't have been copied"
180 fi
181
182 JOBID=`awk -F= '/Job queued. JobId/ {if(!f){print $2; f=1;}}' ${cwd}/tmp/log4.out`
183 get_mig_info $JOBID ${cwd}/tmp/log4.out
184
185 if [ -z "$RET" -o "$RET" = 0 ]; then
186     bstat=2
187     print_debug "The new incremental job must have been copied"
188 fi
189
190 check_two_logs
191 end_test