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