]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restore-by-file-tape
Pull regression truncate-test from Branch-9.1
[bacula/bacula] / regress / tests / restore-by-file-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. There are about 64 files that
12 #   are created during each of the two backups.
13 #
14 TestName="restore-by-file-tape"
15 JobName=restorebyfile
16 . scripts/functions
17
18 require_tape_drive
19
20 scripts/copy-tape-confs
21 scripts/cleanup-tape
22
23 echo "${cwd}/build" >${cwd}/tmp/file-list
24 sed s%\^%${cwd}% ${cwd}/scripts/flist | sort | uniq >${cwd}/tmp/restore2-list
25
26 cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
27 sed "s%# Maximum File Size%  Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
28
29 change_jobname NightlySave $JobName
30 start_test
31
32 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
33 @$out /dev/null
34 messages
35 @$out   ${cwd}/tmp/log1.out
36 label storage=tape volume=TestVolume001 slot=0 pool=Default
37 run job=$JobName level=Full yes
38 wait
39 messages
40 @# 
41 @# now do a restore
42 @#
43 @$out   ${cwd}/tmp/log2.out
44 restore where=${cwd}/tmp/bacula-restores storage=tape file=<${cwd}/tmp/restore2-list
45 yes
46 wait
47 messages
48 quit
49 END_OF_DATA
50
51 run_bacula
52 check_for_zombie_jobs storage=tape
53 stop_bacula
54
55 dstat=0
56 #
57 # We need to stop and start Bacula to
58 #  test appending to a previously written tape
59 #
60 for i in `cat ${cwd}/tmp/restore2-list`; do
61    diff $i ${cwd}/tmp/bacula-restores$i
62    if [ $? != 0 ] ; then
63       dstat=1
64    fi
65 done
66
67 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
68 @$out /dev/null
69 messages
70 @$out   ${cwd}/tmp/log1.out
71 run job=$JobName  level=Full yes
72 wait
73 messages
74 @#
75 @# now do a restore
76 @#
77 @$out   ${cwd}/tmp/log2.out
78 restore where=${cwd}/tmp/bacula-restores
79 7
80 <${cwd}/tmp/restore2-list
81                                                                                         
82 yes
83 wait
84 messages
85 quit
86 END_OF_DATA
87
88 #
89 # Bacula was stopped, but we must restart it to
90 #  test appending to a previously written tape
91 #
92 run_bacula
93 check_for_zombie_jobs storage=tape
94 stop_bacula
95
96 check_two_logs
97
98 scripts/check_for_zombie_jobs storage=tape
99 stop_bacula
100 for i in `cat ${cwd}/tmp/restore2-list`; do
101    diff $i ${cwd}/tmp/bacula-restores$i
102    if [ $? != 0 ] ; then
103       dstat=1
104    fi
105 done
106
107 end_test