]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/fileregexp-test
Backport from BEE
[bacula/bacula] / regress / tests / fileregexp-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory
4 #   prune file records, then restore only README files.
5 #
6 TestName="fileregexp-test"
7 JobName=backup
8 . scripts/functions
9
10 scripts/cleanup
11 scripts/copy-confs
12
13 #
14 # Zap out any schedule in default conf file so that
15 #  it doesn't start during our test
16 #
17 outf="${tmp}/sed_tmp"
18 echo "s%  Schedule =%# Schedule =%g" >${outf}
19 echo "s%File Retention =%File Retention = 2 #%" >>  ${outf}
20 cp ${scripts}/bacula-dir.conf ${tmp}/1
21 sed -f ${outf} ${tmp}/1 >${scripts}/bacula-dir.conf
22
23 change_jobname BackupClient1 $JobName
24 start_test
25
26 cat <<END_OF_DATA >${tmp}/bconcmds
27 @output /dev/null
28 messages
29 @$out ${tmp}/log1.out
30 label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
31 run job=$JobName yes
32 wait
33 messages
34 @sleep 5
35 prune files yes
36 quit
37 END_OF_DATA
38
39 run_bacula
40
41 touch $cwd/build/po/*
42
43 cat <<END_OF_DATA >${tmp}/bconcmds
44 run job=$JobName yes
45 wait
46 messages
47 @# 
48 @# now do a restore
49 @#
50 @$out ${tmp}/log2.out  
51 restore where=${tmp}/bacula-restores
52 5
53 no
54 README
55 yes
56 wait
57 messages
58 END_OF_DATA
59
60 run_bconsole
61
62 check_for_zombie_jobs storage=File1
63 stop_bacula
64
65 #
66 # The above restore should have restored some directories, but only
67 # files that have README in their name.  There should in fact, be
68 # no other files restored COUNT_OTHER==0 and 13 README files restored.
69 # We complain if there are less than 11
70 #
71 COUNT_OTHER=`find ${tmp}/bacula-restores -type f | grep -v README | wc -l`
72 COUNT_README=`find ${tmp}/bacula-restores -type f | grep README | wc -l`
73
74 if [ $COUNT_OTHER -gt 0 -o $COUNT_README -lt 11 ]; then
75     print_debug "Found non matching files"
76     print_debug "Count_other=$COUNT_OTHER count_readme=$COUNT_README"
77     print_debug `find ${tmp}/bacula-restores -type f | grep -v README`
78     rstat=2
79 fi
80
81 #check_two_logs         # don't work because of "warning file count mismatch"
82 grep "Backup OK" ${tmp}/log1.out > /dev/null
83 if [ $? -ne 0 ]; then
84     print_debug "Found error in backup"
85     bstat=2
86 fi
87
88 end_test