]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/recycle-test
Backport from Bacula Enterprise
[bacula/bacula] / regress / tests / recycle-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 but 
9 #   create three volumes and do six backups causing the
10 #   volumes to be recycled, and cycling through the volumes
11 #   twice. Tests maxvoljobs and volretention.
12 #
13 # Note, this test is a bit tricky, in that if you get too
14 #   much data in the regress/build directory, the test will
15 #   fail because it will run out of enough volumes to backup
16 #   all the data.
17 #
18 TestName="recycle-test"
19 JobName=Recycle
20 . scripts/functions
21
22 scripts/cleanup
23 scripts/copy-test-confs
24 echo "${cwd}/build" >${cwd}/tmp/file-list
25
26 change_jobname NightlySave $JobName
27 start_test
28
29 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
30 @output /dev/null
31 messages
32 @$out ${cwd}/tmp/log1.out
33 setdebug level=15 storage=File1
34 label storage=File1 volume=TestVolume001
35 label storage=File1 volume=TestVolume002
36 label storage=File1 volume=TestVolume003
37 label storage=File1 volume=TestVolume004
38 @# Note, this is going to fail if the pruning gets
39 @#  to tight because the saved volume is too large.
40 @#  In that case, either add another volume, or
41 @#  increase the volume capacity a bit.
42 update Volume=TestVolume001 volretention=5s
43 update Volume=TestVolume001 maxvolbytes=250000000
44 update Volume=TestVolume002 volretention=5s
45 update Volume=TestVolume002 maxvolbytes=250000000
46 update Volume=TestVolume003 volretention=5s
47 update Volume=TestVolume003 maxvolbytes=250000000
48 update Volume=TestVolume004 volretention=5s
49 update Volume=TestVolume004 maxvolbytes=250000000
50 sql
51 select mediaid,volumename,volstatus,volbytes,maxvolbytes,voljobs,volretention from Media;
52 select * from JobMedia;
53 select VolumeName,FirstWritten,LastWritten,VolBytes from Media;
54
55 @#setdebug level=110 storage=File1
56 setdebug level=60 dir
57 run job=$JobName storage=File1 level=full yes
58 run job=$JobName storage=File1 level=full yes
59 run job=$JobName storage=File1 level=full yes
60 sql
61 select * from JobMedia;
62 select VolumeName,FirstWritten,LastWritten,VolStatus,VolBytes from Media;
63
64 wait
65 messages
66 sql
67 select mediaid,volumename,volstatus,volbytes,maxvolbytes,voljobs,volretention from Media;
68 select * from JobMedia;
69 select VolumeName,FirstWritten,LastWritten,VolStatus,VolBlocks,VolBytes from Media;
70
71 @sleep 12 
72 run job=$JobName storage=File1 level=full yes
73 run job=$JobName storage=File1 level=full yes
74 run job=$JobName storage=File1 level=full yes
75 sql
76 select * from JobMedia;
77 select VolumeName,FirstWritten,LastWritten,VolStatus,VolBlocks,VolBytes from Media;
78
79 wait
80 messages
81 sql
82 select mediaid,volumename,volstatus,volbytes,maxvolbytes,voljobs,volretention from Media;
83 select * from JobMedia;
84 select VolumeName,FirstWritten,LastWritten,VolStatus,VolBlocks,VolBytes from Media;
85
86 @sleep 12
87 run job=$JobName storage=File1 level=full yes
88 run job=$JobName storage=File1 level=full yes
89 run job=$JobName storage=File1 level=full yes
90 wait
91 messages
92 sql
93 select mediaid,volumename,volstatus,volbytes,maxvolbytes,voljobs,volretention from Media;
94 select * from JobMedia;
95 select VolumeName,FirstWritten,LastWritten,VolStatus,VolBlocks,VolBytes from Media;
96
97 @sleep 12
98 run job=$JobName storage=File1 level=full yes
99 run job=$JobName storage=File1 level=full yes
100 run job=$JobName storage=File1 level=full yes
101 wait
102 messages
103 sql
104 select mediaid,volumename,volstatus,volbytes,maxvolbytes,voljobs,volretention from Media;
105 select * from JobMedia;
106 select VolumeName,FirstWritten,LastWritten,VolStatus,VolBlocks,VolBytes from Media;
107
108 @sleep 12
109 run job=$JobName storage=File1 level=full yes
110 run job=$JobName storage=File1 level=full yes
111 run job=$JobName storage=File1 level=full yes
112 wait
113 messages
114 sql
115 select mediaid,volumename,volstatus,volbytes,maxvolbytes,voljobs,volretention from Media;
116 select * from JobMedia;
117 select VolumeName,FirstWritten,LastWritten,VolStatus,VolBlocks,VolBytes from Media;
118
119 @# 
120 @# now do a restore
121 @#
122 @$out ${cwd}/tmp/log2.out
123 restore where=${cwd}/tmp/bacula-restores select storage=File1
124 unmark *
125 mark *
126 done
127 yes
128 wait
129 messages
130 quit
131 END_OF_DATA
132
133 run_bacula
134 check_for_zombie_jobs storage=File1
135 stop_bacula
136
137 check_two_logs
138 check_restore_diff
139 end_test