]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restart-accurate-job-test
Pull regression truncate-test from Branch-9.1
[bacula/bacula] / regress / tests / restart-accurate-job-test
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 backup of the build directory but force it to have
9 #   a comm error, and check that it restarts correctly.
10 #
11 TestName="restart-accurate-job-test"
12 JobName=RestartJob
13 . scripts/functions
14
15 scripts/cleanup
16 scripts/copy-test-confs
17
18
19 echo "${cwd}/build" >${cwd}/tmp/file-list
20
21 change_jobname NightlySave $JobName
22
23 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'Accurate', 'yes', 'Job', 'RestartJob')"
24 start_test
25 touch $cwd/build/po/testfile
26
27 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
28 @output /dev/null
29 messages
30 @$out ${cwd}/tmp/log1.out
31 label storage=File volume=TestVolume001
32 setdebug level=0 trace=0 hangup=100 client
33 @#setdebug level=20 dir
34 run job=$JobName yes
35 wait
36 messages
37 sql
38 select * from JobMedia;
39
40 quit
41 END_OF_DATA
42
43 run_bacula  
44
45 scripts/check_for_zombie_jobs storage=File
46
47 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
48 @output /dev/null
49 @$out ${cwd}/tmp/log1.out
50 setdebug level=0 trace=0 hangup=50 client
51 @exec "sh -c 'touch $cwd/build/po/*'"
52 @exec "sh -c 'touch $cwd/build/src/dird/*'"
53 @exec "rm $cwd/build/po/testfile"
54 run job=$JobName yes
55 wait
56 messages
57 sql
58 select * from JobMedia;
59
60 @# 
61 @# now do a restore
62 @#
63 @$out ${cwd}/tmp/log2.out
64 restore where=$tmp/bacula-restores storage=File select all done
65 yes
66 wait
67 messages
68 @$out ${cwd}/tmp/log3.out
69 list jobs
70 quit
71 END_OF_DATA
72
73 run_bconsole
74 scripts/check_for_zombie_jobs storage=File
75 stop_bacula
76
77 check_two_logs
78 check_restore_diff
79
80 nb_F=`awk -F '|' '/RestartJob.+F/ { gsub(/,/, ""); print $7}' $tmp/log3.out`
81 nb_I=`awk -F '|' '/RestartJob.+I/ { gsub(/,/, ""); print $7}' $tmp/log3.out`
82 nb1=`ls $cwd/build/po/* $cwd/build/src/dird/* | wc -l`
83 nb1=`expr $nb1 + 50`
84
85 if [ "$nb_I" -eq "$nb_F" ]; then
86     print_debug "ERROR: Incremental saves too much files (nb Incr == nb Full)"
87     estat=1
88 fi
89
90 if [ "$nb_I" -ge "$nb1" ]; then
91     print_debug "ERROR: Incremental saves too much files (more than $nb1)"
92     estat=1
93 fi
94
95 end_test