1#!/bin/sh
2#
3# This script will test prune algo
4#
5. scripts/functions
6
7TestName="prune-test"
8JobName=NightlySave
9
10scripts/cleanup
11scripts/copy-test-confs
12
13
14# We want to have pruning only when doing prune command
15$bperl -e 'add_attribute("$conf/bareos-dir.conf", "AutoPrune", "No", "Client")'
16$bperl -e 'add_attribute("$conf/bareos-dir.conf", "Job Retention", "1s", "Client")'
17
18# Add a new job with a different fileset
19$bperl -e 'print get_resource("$conf/bareos-dir.conf", "Job", "NightlySave")' | \
20    sed s/NightlySave/DailySave/ | sed 's/Full Set/CompressedSet/' > $tmp/1
21
22# Directory to backup.
23# This directory will be created by setup_data().
24BackupDirectory="${tmp}/data"
25
26# Use a tgz to setup data to be backuped.
27# Data will be placed at "${tmp}/data/".
28setup_data data/small.tgz
29
30# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
31echo "${BackupDirectory}" >${tmp}/file-list
32
33
34start_test
35
36cat <<EOF > ${cwd}/tmp/bconcmds
37@$out /dev/null
38messages
39@$out $tmp/log1.out
40label storage=File volume=TestVolume001
41run job=$JobName level=full yes
42wait
43messages
44@exec "touch $BackupDirectory/fr.po"
45run job=$JobName level=incremental yes
46wait
47messages
48@exec "touch $BackupDirectory/de.po"
49run job=$JobName level=incremental yes
50wait
51messages
52@# run a second set of backup
53run job=DailySave level=full yes
54wait
55messages
56@exec "touch $BackupDirectory/fr.po"
57run job=DailySave level=incremental yes
58wait
59messages
60@exec "touch $BackupDirectory/de.po"
61run job=DailySave level=incremental yes
62wait
63messages
64@sleep 2
65@$out $tmp/log10.out
66@# should prune nothing
67list jobs
68prune jobs jobtype=backup yes
69list jobs
70quit
71EOF
72
73run_bareos
74
75# should find nothing to prune
76$bperl -e "check_prune_list('$tmp/log10.out')"
77
78# rename the job to see if it's pruned
79sed s/DailySave/DisabledBackup/ $conf/bareos-dir.conf > $tmp/1
80mv $tmp/1 $conf/bareos-dir.conf
81
82cat <<EOF > ${cwd}/tmp/bconcmds
83@$out tmp/log11.out
84reload
85messages
86@# should prune jobs using DailySave
87list jobs
88prune jobs jobtype=backup yes
89list jobs
90EOF
91
92run_bconsole
93
94$bperl -e "check_prune_list('$tmp/log11.out', 4, 5, 6)"
95estat=$(($estat + $?))
96
97# rename Full Set fileset to see if it will be pruned the next time
98$bperl -e 'add_attribute("$conf/bareos-dir.conf", "FileSet", "CompressedSet", "Job", "NightlySave")'
99sed "s/Full Set/DisFullSet/g" $conf/bareos-dir.conf > $tmp/1
100mv $tmp/1 $conf/bareos-dir.conf
101
102cat <<EOF > ${cwd}/tmp/bconcmds
103@$out tmp/log12.out
104reload
105messages
106@# should prune jobs using Full Set
107list jobs
108prune jobs jobtype=backup yes
109list jobs
110EOF
111
112run_bconsole
113
114$bperl -e "check_prune_list('$tmp/log12.out', 1, 2, 3)"
115estat=$(($estat + $?))
116
117check_for_zombie_jobs storage=File
118stop_bareos
119
120touch $tmp/log2.out
121check_two_logs
122
123end_test
124