/
prune-migration-test
executable file
·107 lines (94 loc) · 2.53 KB
/
prune-migration-test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
#
# Run a simple backup of the Bareos build directory then migrate it
# to another device, then see how prune code handle that
#
# This script uses the virtual disk autochanger
#
TestName="prune-migration-test"
JobName=MigrationJobSave
. scripts/functions
scripts/cleanup
scripts/copy-migration-confs
scripts/prepare-disk-changer
echo "${cwd}/build" >${cwd}/tmp/file-list
change_jobname NightlySave $JobName
dircfg=$conf/bareos-dir.conf
$bperl -e "add_attribute('$dircfg', 'AutoPrune', 'No', 'Client')"
$bperl -e "add_attribute('$dircfg', 'Job Retention', '1s', 'Client')"
start_test
#
# Note, we first backup into Pool Default,
# then Migrate into Pool Full.
# Pool Default uses Storage=File
# Pool Full uses Storage=DiskChanger
# Write out bconsole commands
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out /dev/null
messages
@$out ${cwd}/tmp/log1.out
setdebug level=000 storage=File
label storage=File volume=FileVolume001 Pool=Default
label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
@# run two jobs (both will be migrated)
run job=$JobName yes
@sleep 2
run job=$JobName yes
@sleep 2
wait
list jobs
@# should migrate two jobs
run job=migrate-job yes
wait
messages
list jobs
wait
@sleep 2
@#
@# Now do another backup, but level Incremental
@#
run job=$JobName level=Incremental yes
wait
messages
@sleep 2
@################################################################
@$out $cwd/tmp/log10.out
setdebug level=1 director
sql
SELECT JobId, JobTDate, StartTime, EndTime FROM Job;
list jobs
prune jobs jobtype=backup yes
@sleep 90
list jobs
sql
SELECT JobId, JobTDate, StartTime, EndTime FROM Job;
@################################################################
@# now do a restore
@#
@$out ${cwd}/tmp/log2.out
list volumes
restore where=${cwd}/tmp/bareos-restores select storage=DiskChanger
unmark *
mark *
done
yes
list volumes
wait
messages
quit
END_OF_DATA
run_bareos
check_for_zombie_jobs storage=File
stop_bareos
check_two_logs
check_restore_diff
# Now we will verify that the pruning code is working as expected. Each time,
# we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
# in argument are present in the first 'list jobs', the 'prune' command deletes
# them (same number), and checks that the last 'list jobs' doesn't contain them
# anymore. See scripts/functions.pm for details.
# M M g g F F I0 -> F
$bperl -e "check_prune_list('$tmp/log10.out',1,2,5,8)"
estat=$(($estat + $?))
end_test