3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
7 TestName="action-on-purge-test"
13 scripts/copy-test-confs
15 echo $src > $tmp/file-list
17 sed 's/Pool Type = Backup/Pool Type = Backup; ActionOnPurge = Truncate/' $conf/bacula-dir.conf > $tmp/1
18 cp $tmp/1 $conf/bacula-dir.conf
22 cat >tmp/bconcmds <<END_OF_DATA
26 label storage=File volume=TestVolume001
27 @########################################################
28 @# Run a first job on TestVolume001
29 @########################################################
30 run level=full job=$JobName yes
34 @#restore where=${cwd}/tmp/bacula-restores select all storage=File done
38 @#########################################################
39 @# Run a second job on TestVolume002
40 @#########################################################
42 label storage=File volume=TestVolume002
43 update volume=TestVolume001 volstatus=Used
47 run level=full job=$JobName yes
50 @#########################################################
51 @# Run a 3th job on TestVolume003
52 @#########################################################
54 update volume=TestVolume002 volstatus=Used
55 label storage=File volume=TestVolume003
59 run level=full job=$JobName yes
62 @#########################################################
64 @#########################################################
66 update volume=TestVolume003 volstatus=Used
67 label storage=File volume=TestVolume004
70 run level=full job=$JobName yes
75 update volume=TestVolume004 volstatus=Used
76 label storage=File volume=TestVolume005
77 run level=full job=$JobName yes
81 @#########################################################
83 @#########################################################
84 update volume=TestVolume002 actiononpurge=none
85 purge volume=TestVolume001
86 purge volume=TestVolume002
87 purge volume=TestVolume003
88 purge volume=TestVolume004
91 select VolumeName, VolStatus, ActionOnPurge FROM Media;
93 setdebug level=100 director
98 check_for_zombie_jobs storage=File
100 print_debug "Check all media"
101 for i in 1 2 3 4 5 ; do
102 size=`du -b $tmp/TestVolume00$i|cut -f1`
103 if test $size -lt 5000 ; then
104 print_debug "ERROR 2: Volume TestVolum00$i is too small $size"
105 ls -l $tmp/TestVolume00$i
110 echo "purge volume=TestVolume001 action storage=File" > $tmp/bconcmds
113 for i in 2 3 4 5 ; do
114 size=`du -b $tmp/TestVolume00$i|cut -f1`
115 if test $size -lt 5000 ; then
116 print_debug "ERROR 3: Volume TestVolum00$i is too small $size"
117 ls -l $tmp/TestVolume00$i
122 size=`du -b $tmp/TestVolume00$i|cut -f1`
123 if test $size -gt 5000 ; then
124 print_debug "ERROR 4: Volume TestVolum00$i is not truncated (too big) $size"
125 ls -l $tmp/TestVolume00$i
130 echo "purge volume action storage=File" > $tmp/bconcmds
134 size=`du -b $tmp/TestVolume00$i|cut -f1`
135 if test $size -lt 5000 ; then
136 print_debug "ERROR 5: Volume TestVolum00$i is too small $size"
137 ls -l $tmp/TestVolume00$i
142 size=`du -b $tmp/TestVolume00$i|cut -f1`
143 if test $size -gt 5000 ; then
144 print_debug "ERROR 6: Volume TestVolum00$i is not truncated (too big) $size"
145 ls -l $tmp/TestVolume00$i
150 cat <<END_OF_DATA > $tmp/bconcmds
151 @#########################################################
152 @# Display catalog settings for Pool and Media
153 @#########################################################
155 setdebug level=0 director
157 select VolumeName, ActionOnPurge FROM Media;
158 select Name, ActionOnPurge FROM Pool;
171 print_debug "Test if Pool record is ok"
172 r=`awk '/Default/ { print $4 }' $tmp/log4.out`
173 if [ "$r" != 1 ]; then
174 print_debug "ActionOnPurge on Pool record should be 1 ($r)"
178 print_debug "Test TestVolume001 if Media record is ok"
179 r=`awk '/TestVolume001/ { print $4 }' $tmp/log4.out`
180 if [ "$r" != 1 ]; then
181 print_debug "ActionOnPurge on Media record should be 1"
185 print_debug "Test TestVolume002 if Media record is ok"
186 r=`awk '/TestVolume002/ { print $4 }' $tmp/log4.out`
187 if [ "$r" != 0 ]; then
188 print_debug "ActionOnPurge on Media record should be 0"