3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # This script will test prune algo
10 TestName="prune-pool-test"
14 scripts/copy-test-confs
18 echo $PWD/build/po > tmp/file-list
20 dircfg=$conf/bacula-dir.conf
22 # copy the Default pool to Special pool
27 Recycle = yes # Bacula can automatically recycle Volumes
28 AutoPrune = yes # Prune expired volumes
29 Volume Retention = 365d # one year
35 $bperl -e "add_attribute('$dircfg', 'AutoPrune', 'No', 'Client')"
36 $bperl -e "add_attribute('$dircfg', 'Job Retention', '1s', 'Client')"
37 $bperl -e "add_attribute('$dircfg', 'File Retention', '1s', 'Client')"
39 cat <<EOF > ${cwd}/tmp/bconcmds
43 label storage=File pool=Default volume=TestVolume001
44 label storage=File pool=Special volume=TestVolume002
45 run job=$JobName pool=Default level=full yes
48 @exec "touch $cwd/build/po/fr.po"
49 run job=$JobName pool=Special level=incremental yes
52 @exec "touch $cwd/build/po/de.po"
53 run job=$JobName pool=Special level=incremental yes
56 @exec "touch $cwd/build/po/es.po"
57 run job=$JobName level=incremental yes
60 run job=$JobName pool=Default level=Differential yes
65 @################################################################
66 @# Should not prune anything
67 @#setdebug level=50 director
68 prune files pool=Special yes
72 prune jobs pool=Special yes
74 @################################################################
76 prune files pool=Default yes
79 prune jobs pool=Default yes
81 @################################################################
83 @# Should prune incrementals
89 @#setdebug level=0 director
90 @################################################################
92 restore where=${cwd}/tmp/bacula-restores select all storage=File done
101 check_for_zombie_jobs storage=File
108 ###############################################################################
109 # Now we will verify that the pruning code is working as expected. Each time,
110 # we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
111 # in argument are present in the first 'list jobs', the 'prune' command deletes
112 # them (same number), and checks that the last 'list jobs' doesn't contain them
113 # anymore. See scripts/functions.pm for details.
115 # nothing should be pruned
116 $bperl -e "check_prune_list('$tmp/log3.out')"
117 estat=$(($estat + $?))
119 # should prune only Default incremental
120 # F I I I D -> F I I D
121 $bperl -e "check_prune_list('$tmp/log5.out', 4)"
122 estat=$(($estat + $?))
124 # we should find fr.po in list files of jobid 2
125 grep po/fr.po $tmp/log3.out > /dev/null
126 estat=$(($estat + $?))
128 # we should find es.po in list files of jobid 4
129 grep po/es.po $tmp/log3.out > /dev/null
130 estat=$(($estat + $?))
132 # jobids 2 and 3 should be pruned
133 # (F I I I D) -> (F D)
134 $bperl -e "check_prune_list('$tmp/log4.out',2,3)"
135 estat=$(($estat + $?))
137 # we should not find fr.po in list files of jobid 2
138 grep po/fr.po $tmp/log4.out > /dev/null
140 print_debug "ERROR: found fr.po in $tmp/log4.out after the prune file"
141 estat=$(($estat + 1))
144 # we should not find es.po in list files of jobid 3
145 grep po/es.po $tmp/log5.out > /dev/null
147 print_debug "ERROR: found es.po in $tmp/log5.out after the prune file"
148 estat=$(($estat + 1))