]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restore-seek-tape
regress: test restore object in plugin-test
[bacula/bacula] / regress / tests / restore-seek-tape
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory 
4 #   to a tape where the maximum tape file size is set to 1M
5 #   then restore a few files from it.  Note, by setting the maximum 
6 #   file size to 1M, it runs very slow. This tests the
7 #   seeking capability
8 #
9 TestName="restore-seek-tape"
10 JobName=restore-tape-seek
11 . scripts/functions
12
13 require_tape_drive
14
15 scripts/copy-tape-confs
16 scripts/cleanup-tape
17
18 echo "${cwd}/tmp/build" >${cwd}/tmp/file-list
19 rm -rf ${cwd}/tmp/build
20 mkdir -p ${cwd}/tmp/build
21 # Copy only the .c files (to be restored)
22 #  set files to "*.c" for all c files
23 files="ua_tree.c ua_update.c"
24 # files="*.c"
25 for i in ${files}; do
26    cp -p ${cwd}/build/src/dird/${i} ${cwd}/tmp/build
27 done
28 cd ${cwd}/tmp/build
29 ls >../1
30 cd ..
31 sed s%\^%${cwd}/tmp/build/% 1 | sort | uniq >restore-list
32 #
33 # At this point restore-list contains the list
34 #  of files we will restore
35 #
36 rm -f 1
37 cd ${cwd}
38 #
39 # Now arrange to backup *everything*
40 #
41 rm -rf  ${cwd}/tmp/build
42 mkdir -p ${cwd}/tmp/build
43 cp -fp ${cwd}/build/src/dird/* ${cwd}/tmp/build
44 #
45 # Enable MaximumFileSize to ensure lots of JobMedia records and thus
46 #  lots of seeking
47 #
48 cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
49 sed "s%# Maximum File Size = 1000000%  Maximum File Size = 10KB%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
50
51 change_jobname NightlySave $JobName
52 start_test
53
54 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
55 @$out /dev/null
56 messages
57 @$out ${cwd}/tmp/log1.out
58 label storage=tape volume=TestVolume001 pool=Default
59 run job=$JobName yes
60 wait
61 messages
62 @#
63 @# now do a restore
64 @#
65 @$out ${cwd}/tmp/log2.out
66 setdebug level=30 fd
67 setdebug level=10 storage=tape
68 sql
69 @# print the JobMedia records
70 select * from JobMedia;
71
72 restore bootstrap=${cwd}/tmp/kern.bsr where=${cwd}/tmp/bacula-restores storage=tape
73 7
74 <${cwd}/tmp/restore-list
75
76 yes
77 wait
78 messages
79 quit
80 END_OF_DATA
81
82 run_bacula
83 check_for_zombie_jobs storage=tape
84 stop_bacula
85
86 # Now setup a control directory of only what we *should* restore
87 rm -rf ${cwd}/tmp/build
88 mkdir -p  ${cwd}/tmp/build
89 for i in ${files}; do
90    cp -p ${cwd}/build/src/dird/${i} ${cwd}/tmp/build
91 done
92
93 check_two_logs
94 check_restore_tmp_build_diff
95 end_test