3 # Run a simple backup of the Bacula build directory then create some
4 # new files, do an Incremental and restore those two files.
5 # test the bvfs interface
12 ${rscripts}/copy-test-confs
13 echo "${tmpsrc}" >${tmp}/file-list
14 echo "${cwd}/build" >> ${tmp}/file-list
17 cp -p ${src}/src/dird/*.c ${tmpsrc}
19 echo "${tmpsrc}/ficheriro1.txt" >restore-list
20 echo "${tmpsrc}/ficheriro2.txt" >>restore-list
23 change_jobname CompressedTest $JobName
26 cat <<END_OF_DATA >${tmp}/bconcmds
30 label storage=File volume=TestVolume001
31 label storage=File volume=TestVolume002
39 check_for_zombie_jobs storage=File
41 # Now create two new files to be restored later
44 echo "ficheriro1.txt" >${tmpsrc}/ficheriro1.txt
45 cp -f ${tmpsrc}/dird.c ${tmpsrc}/ficheriro2.txt
47 cat <<END_OF_DATA >${tmp}/bconcmds
51 @# Force Incremental on the second Volume
52 update volume=TestVolume001 VolStatus=Used
53 run level=Differential job=$JobName yes
62 touch ${tmpsrc}/ficheriro1.txt
63 touch ${tmpsrc}/ficheriro2.txt
65 cat <<END_OF_DATA >${tmp}/bconcmds
69 run level=Incremental job=$JobName yes
79 cp -f ficheriro2.txt 1
80 sed "s%a%b%g" 1 >ficheriro2.txt
83 cat <<END_OF_DATA >${tmp}/bconcmds
87 run level=Differential job=$JobName yes
96 touch ${tmpsrc}/ficheriro1.txt
97 touch ${tmpsrc}/ficheriro2.txt
98 cat <<END_OF_DATA >${tmp}/bconcmds
101 @$out ${tmp}/log1.out
102 run level=Incremental job=$JobName yes
111 touch ${tmpsrc}/ficheriro1.txt
112 touch ${tmpsrc}/ficheriro2.txt
113 cat <<END_OF_DATA >${tmp}/bconcmds
116 @$out ${tmp}/log1.out
117 run level=Incremental job=$JobName yes
126 touch ${tmpsrc}/ficheriro1.txt
127 touch ${tmpsrc}/ficheriro2.txt
128 cat <<END_OF_DATA >${tmp}/bconcmds
131 @$out ${tmp}/log1.out
132 run level=Incremental job=$JobName yes
140 cat /etc/hosts >> ${tmpsrc}/ficheriro1.txt
141 rm -f ${tmpsrc}/dird_conf.c
142 touch ${tmpsrc}/ficheriro2.txt
143 ln ${tmpsrc}/ficheriro2.txt ${tmpsrc}/hardlink2
145 cat <<END_OF_DATA >${tmp}/bconcmds
148 @$out ${tmp}/log1.out
149 run level=Incremental accurate=yes job=$JobName
153 @$out ${tmp}/log3.out
155 .bvfs_lsdir path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8
156 .bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8
157 @$out ${tmp}/log31.out
158 .bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7
164 cat <<END_OF_DATA >${tmp}/bconcmds
166 .bvfs_cleanup path=b21
170 # we look in the lsdir/lsfiles output to get filenameid and pathid for version and restore
171 awk '/ficheriro1.txt/ {
172 print ".bvfs_versions jobid=" $4 " fnid=" $2 " pathid=" $1 " client='$CLIENT'"
173 print ".bvfs_restore jobid=" $4 " fileid=" $3 " path=b21"
174 } ' $tmp/log3.out >> $tmp/bconcmds
176 cat <<END_OF_DATA >>${tmp}/bconcmds
177 restore file="?b21" where=$tmp/bacula-restores yes
185 diff $tmpsrc/ficheriro1.txt $tmp/bacula-restores/$tmpsrc/ficheriro1.txt &>> $tmp/d1
187 print_debug "ERROR: ficheriro1.txt is different"
191 rm -rf $tmp/bacula-restores
193 cat <<END_OF_DATA >${tmp}/bconcmds
195 @# Try to restore a directory
196 .bvfs_cleanup path=b21
199 awk '/ficheriro2.txt/ {
200 print ".bvfs_restore jobid=1,2,3,4,5,6,7,8 dirid=" $1 " path=b21"
201 } ' $tmp/log3.out >> $tmp/bconcmds
203 cat <<END_OF_DATA >>${tmp}/bconcmds
205 restore file="?b21" where=$tmp/bacula-restores yes
213 $rscripts/diff.pl -s $tmpsrc/ -d $tmp/bacula-restores/$tmpsrc/
215 print_debug "ERROR: Found error while restoring a directory"
219 diff $tmpsrc/ficheriro2.txt $tmp/bacula-restores/$tmpsrc/ficheriro2.txt
221 print_debug "ERROR: ficheriro2.txt is different"
225 rm -rf $tmp/bacula-restores
227 cat <<END_OF_DATA >${tmp}/bconcmds
229 @# Try to restore a hardlinks
230 .bvfs_cleanup path=b21
233 jidx=`awk -F '\t' '/ficheriro2.txt|hardlinks2/ { lstat=$5 }
234 END { print ".bvfs_decode_lstat lstat=\"" lstat "\""
235 } ' $tmp/log3.out | $bin/bconsole -c $conf/bconsole.conf | awk -F= '/LinkFI/ { print $2 } '`
237 awk '/ficheriro2.txt/ { if (!id) { id=$3 } } /hardlink2/ { if (!id) { id=$3 } }
239 print ".bvfs_restore jobid=1,2,3,4,5,6,7,8 hardlink=8,'$jidx' fileid=" id " path=b21"
240 } ' $tmp/log3.out >> $tmp/bconcmds
242 cat <<END_OF_DATA >>${tmp}/bconcmds
244 restore file="?b21" where=$tmp/bacula-restores yes
252 test -f $tmp/bacula-restores/$tmpsrc/hardlink2 -a -f $tmp/bacula-restores/$tmpsrc/ficheriro2.txt
254 print_debug "ERROR: Need to get all files"
259 ls -i $tmp/bacula-restores/$tmpsrc/hardlink2 | awk ' { print $1 } ' > $tmp/1
260 ls -i $tmp/bacula-restores/$tmpsrc/ficheriro2.txt | awk ' { print $1 } ' > $tmp/2
261 diff $tmp/1 $tmp/2 > /dev/null
263 print_debug "ERROR: Both files should have the same inode number"
267 check_for_zombie_jobs storage=File
272 grep dird_conf.c $tmp/log3.out > /dev/null
274 print_debug "ERROR: Should not find dird_conf.c in bvfs_lsfiles output $tmp/log3.out"
278 grep dird_conf.c $tmp/log31.out > /dev/null
280 print_debug "ERROR: Should find dird_conf.c in bvfs_lsfiles output $tmp/log31.out"
285 # Delete .c files because we will only restored the txt files
288 #check_restore_tmp_build_diff
290 #${cwd}/build/src/tools/bvfs_test -T -p ${tmpsrc} -j 1,2,3,4,5,6,7,8 \
291 # -w "$working" -n "$db_name" -u "$db_user" -P "$db_password"
293 #${cwd}/build/src/tools/bvfs_test -p ${cwd}/build/ -j 1,2,3,4,5,6,7,8 \
294 # -w "$working" -n "$db_name" -u "$db_user" -P "$db_password"
296 #${cwd}/build/src/tools/bvfs_test -p ${tmpsrc} -j 1,2,3,4,5,6,7,8 \
297 # -w "$working" -n "$db_name" -u "$db_user" -P "$db_password" \
298 # -f ficheriro1.txt -c ${HOST}-fd