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