]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/2drive-incremental-2disk
regress: make truncate-test check for wrongly truncating an already truncated volume
[bacula/bacula] / regress / tests / 2drive-incremental-2disk
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 then create some           
9 #   new files, do an Incremental and restore those two files.
10 #
11 # This script uses the virtual disk autochanger and two drives
12 #
13 TestName="2drive-incremental-2disk"
14 JobName="2drive2disk"
15 . scripts/functions
16
17 scripts/cleanup
18 scripts/copy-2disk-drive-confs
19 scripts/prepare-disk-changer
20 CLIENT=2drive2disk
21
22 change_jobname localhost-fd $JobName
23 start_test
24
25 echo "${cwd}/tmp/build" >${cwd}/tmp/file-list
26 if test ! -d ${cwd}/tmp/build ; then
27    mkdir -p ${cwd}/tmp/build
28 fi
29 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
30 cd ${cwd}/tmp
31 echo "${cwd}/tmp/build/ficheriro1.txt" >restore-list
32 echo "${cwd}/tmp/build/ficheriro2.txt" >>restore-list
33 cd ${cwd}
34
35 # Turn off Prefer Mounted Volumes so we use 2 drives
36 outf="${cwd}/tmp/sed_tmp"
37 echo "s%# Prefer Mounted Volumes%  Prefer Mounted Volumes%g" >${outf}
38 cp ${cwd}/bin/bacula-dir.conf ${cwd}/tmp/1
39 # Comment the next line out to write everything to one drive
40 #  otherwise, it writes the two jobs to different drives
41 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
42
43 # Write out bconsole commands
44 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
45 @$out /dev/null
46 messages
47 @$out ${cwd}/tmp/log1.out
48 setdebug level=3 dir
49 setdebug level=3 storage=tape
50 setdebug level=3 client=2drive2disk 
51 label storage=tape volume=TestVolume001 slot=1 Pool=Default drive=0
52 label storage=tape volume=TestVolume002 slot=2 Pool=Default drive=1
53 status storage=tape
54 setdebug level=200 storage=tape
55 run job=NightlySave yes
56 run job=NightlySave yes
57 run job=NightlySave yes
58 run job=NightlySave yes
59 run job=NightlySave yes
60 wait jobid=2
61 status storage=tape
62 list volumes
63 list jobs
64 messages
65 wait
66 list volumes
67 list jobs
68 status storage=tape
69 messages
70 quit
71 END_OF_DATA
72
73 run_bacula
74 echo "ficheriro1.txt" >${cwd}/tmp/build/ficheriro1.txt
75 echo "ficheriro2.txt" >${cwd}/tmp/build/ficheriro2.txt
76
77
78 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
79 @$out /dev/null
80 messages
81 @$out ${cwd}/tmp/log1.out
82 @# Force Incremental on the second Volume
83 update volume=TestVolume001 VolStatus=Used
84 status storage=tape
85 list volumes
86 @#setdebug level=120 storage=tape
87 run level=Incremental job=NightlySave yes
88 wait
89 list volumes
90 status storage=tape
91 messages
92 @# 
93 @# now do a restore
94 @#
95 @$out ${cwd}/tmp/log2.out
96 restore where=${cwd}/tmp/bacula-restores 
97 7
98 <${cwd}/tmp/restore-list
99
100 yes
101 wait
102 messages
103 quit
104 END_OF_DATA
105
106 run_bconsole
107
108 check_for_zombie_jobs storage=tape
109
110 stop_bacula
111
112 check_two_logs
113 # The restore should read from TestVolume002, which was on drive 1
114 grep TestVolume002 ${cwd}/tmp/log2.out >/dev/null 2>&1
115 # Note rstat may already be set, so we don't just store into it
116 if [ $? != 0 ] ; then
117    rstat=$?
118 fi
119
120 #
121 # Delete .c files because we will only restored the txt files
122 #
123 rm -f ${cwd}/tmp/build/*.c
124 check_restore_tmp_build_diff
125
126 end_test