]> git.sur5r.net Git - bacula/docs/blob - docs/manual/pools.tex
Always update Bacula date in manual
[bacula/docs] / docs / manual / pools.tex
1 %%
2 %%
3
4 \section*{Automated Disk Backup}
5 \label{_ChapterStart11}
6 \index[general]{Volumes!Using Pools to Manage }
7 \index[general]{Disk!Automated Backup}
8 \index[general]{Using Pools to Manage Volumes }
9 \index[general]{Automated Disk Backup}
10 \addcontentsline{toc}{section}{Using Pools to Manage Volumes}
11 \addcontentsline{toc}{section}{Automated Disk Backup}
12
13 If you manage 5 or 10 machines and have a nice tape backup, you don't need
14 Pools, and you may wonder what they are good for. In this chapter, you will
15 see that Pools can help you optimize disk storage space. The same techniques
16 can be applied to a shop that has multiple tape drives, or that wants to mount
17 various different Volumes to meet their needs. 
18
19 The rest of this chapter will give an example involving backup to disk
20 Volumes, but most of the information applies equally well to tape Volumes. 
21
22 \label{TheProblem}
23 \subsection*{The Problem}
24 \index[general]{Problem }
25 \addcontentsline{toc}{subsection}{Problem}
26
27 A site that I administer (a charitable organization) had a tape DDS-3 tape
28 drive that was failing. The exact reason for the failure is still unknown.
29 Worse yet, their full backup size is about 15GB whereas the capacity of their
30 broken DDS-3 was at best 8GB (rated 6/12). A new DDS-4 tape drive and the
31 necessary cassettes was more expensive than their budget could handle. 
32 \label{TheSolution}
33
34 \subsection*{The Solution}
35 \index[general]{Solution }
36 \addcontentsline{toc}{subsection}{Solution}
37
38 They want to maintain 6 months of backup data, and be able to access the old
39 files on a daily basis for a week, a weekly basis for a month, then monthly
40 for 6 months. In addition, offsite capability was not needed (well perhaps
41 it really is, but it was never used). Their daily changes amount to about
42 300MB on the average, or about 2GB per week. 
43
44 As a consequence, the total volume of data they need to keep to meet their
45 needs is about 100GB (15GB x 6 + 2GB x 5 + 0.3 x 7) = 102.1GB. 
46
47 The chosen solution was to buy a 120GB hard disk for next to nothing -- far
48 less than 1/10th the price of a tape drive and the cassettes to handle the
49 same amount of data, and to have Bacula write to disk files. 
50
51 The rest of this chapter will explain how to setup Bacula so that it would
52 automatically manage a set of disk files with the minimum intervention on my
53 part. The system has been running since 22 January 2004 until today (08 April
54 2004) with no intervention. Since we have not yet crossed the six month
55 boundary, we still lack some data to be sure the system performs as desired. 
56 \label{OverallDesign}
57
58 \subsection*{Overall Design}
59 \index[general]{Overall Design }
60 \index[general]{Design!Overall }
61 \addcontentsline{toc}{subsection}{Overall Design}
62
63 Getting Bacula to write to disk rather than tape in the simplest case is
64 rather easy, and is documented in the previous chapter. In addition, all the
65 directives discussed here are explained in that chapter. We'll leave it to you
66 to look at the details there. If you haven't read it and are not familiar with
67 Pools, you probably should at least read it once quickly for the ideas before
68 continuing here. 
69
70 One needs to consider about what happens if we have only a single large Bacula
71 Volume defined on our hard disk. Everything works fine until the Volume fills,
72 then Bacula will ask you to mount a new Volume. This same problem applies to
73 the use of tape Volumes if your tape fills. Being a hard disk and the only one
74 you have, this will be a bit of a problem. It should be obvious that it is
75 better to use a number of smaller Volumes and arrange for Bacula to
76 automatically recycle them so that the disk storage space can be reused. The
77 other problem with a single Volume, is that at the current time (1.34.0)
78 Bacula does not seek within a disk Volume, so restoring a single file can take
79 more time than one would expect. 
80
81 As mentioned, the solution is to have multiple Volumes, or files on the disk.
82 To do so, we need to limit the use and thus the size of a single Volume, by
83 time, by number of jobs, or by size. Any of these would work, but we chose to
84 limit the use of a single Volume by putting a single job in each Volume with
85 the exception of Volumes containing Incremental backup where there will be 6
86 jobs (a week's worth of data) per volume. The details of this will be
87 discussed shortly. 
88
89 The next problem to resolve is recycling of Volumes. As you noted from above,
90 the requirements are to be able to restore monthly for 6 months, weekly for a
91 month, and daily for a week. So to simplify things, why not do a Full save
92 once a month, a Differential save once a week, and Incremental saves daily.
93 Now since each of these different kinds of saves needs to remain valid for
94 differing periods, the simplest way to do this (and possibly the only) is to
95 have a separate Pool for each backup type. 
96
97 The decision was to use three Pools: one for Full saves, one for Differential
98 saves, and one for Incremental saves, and each would have a different number
99 of volumes and a different Retention period to accomplish the requirements. 
100 \label{FullPool}
101
102 \subsubsection*{Full Pool}
103 \index[general]{Pool!Full }
104 \index[general]{Full Pool }
105 \addcontentsline{toc}{subsubsection}{Full Pool}
106
107 Putting a single Full backup on each Volume, will require six Full save
108 Volumes, and a retention period of six months. The Pool needed to do that is: 
109
110 \footnotesize
111 \begin{verbatim}
112 Pool {
113   Name = Full-Pool
114   Pool Type = Backup
115   Recycle = yes
116   AutoPrune = yes
117   Volume Retention = 6 months
118   Accept Any Volume = yes
119   Maximum Volume Jobs = 1
120   Label Format = Full-
121   Maximum Volumes = 6
122 }
123 \end{verbatim}
124 \normalsize
125
126 Since these are disk Volumes, no space is lost by having separate Volumes for
127 each backup (done once a month in this case). The items to note are the
128 retention period of six months (i.e. they are recycled after 6 months), that
129 there is one job per volume (Maximum Volume Jobs = 1), the volumes will be
130 labeled Full-0001, ... Full-0006 automatically. One could have labeled these
131 manual from the start, but why not use the features of Bacula. 
132 \label{DiffPool}
133
134 \subsubsection*{Differential Pool}
135 \index[general]{Pool!Differential }
136 \index[general]{Differential Pool }
137 \addcontentsline{toc}{subsubsection}{Differential Pool}
138
139 For the Differential backup Pool, we choose a retention period of a bit longer
140 than a month and ensure that there is at least one Volume for each of the
141 maximum of five weeks in a month. So the following works: 
142
143 \footnotesize
144 \begin{verbatim}
145 Pool {
146   Name = Diff-Pool
147   Pool Type = Backup
148   Recycle = yes
149   AutoPrune = yes
150   Volume Retention = 40 days
151   Accept Any Volume = yes
152   Maximum Volume Jobs = 1
153   Label Format = Diff-
154   Maximum Volumes = 6
155 }
156 \end{verbatim}
157 \normalsize
158
159 As you can see, the Differential Pool can grow to a maximum of six volumes,
160 and the Volumes are retained 40 days and thereafter they can be recycled. Finally
161 there is one job per volume. This, of course, could be tightened up a lot, but
162 the expense here is a few GB which is not too serious. 
163 \label{IncPool}
164
165 \subsubsection*{Incremental Pool}
166 \index[general]{Incremental Pool }
167 \index[general]{Pool!Incremental }
168 \addcontentsline{toc}{subsubsection}{Incremental Pool}
169
170 Finally, here is the resource for the Incremental Pool: 
171
172 \footnotesize
173 \begin{verbatim}
174 Pool {
175   Name = Inc-Pool
176   Pool Type = Backup
177   Recycle = yes
178   AutoPrune = yes
179   Volume Retention = 20 days
180   Accept Any Volume = yes
181   Maximum Volume Jobs = 6
182   Label Format = Inc-
183   Maximum Volumes = 5
184 }
185 \end{verbatim}
186 \normalsize
187
188 We keep the data for 20 days rather than just a week as the needs require. To
189 reduce the proliferation of volume names, we keep a week's worth of data (6
190 incremental backups) in each Volume. In practice, the retention period should
191 be set to just a bit more than a week and keep only two or three volumes
192 instead of five. Again, the lost is very little and as the system reaches the
193 full steady state, we can adjust these values so that the total disk usage
194 doesn't exceed the disk capacity. 
195 \label{Example}
196
197 \subsection*{The Actual Conf Files}
198 \index[general]{Files!Actual Conf }
199 \index[general]{Actual Conf Files }
200 \addcontentsline{toc}{subsection}{Actual Conf Files}
201
202 The following example shows you the actual files used, with only a few minor
203 modifications to simplify things. 
204
205 The Director's configuration file is as follows: 
206
207 \footnotesize
208 \begin{verbatim}
209 Director {          # define myself
210   Name = bacula-dir
211   DIRport = 9101
212   QueryFile = "/home/bacula/bin/query.sql"
213   WorkingDirectory = "/home/bacula/working"
214   PidDirectory = "/home/bacula/working"
215   Maximum Concurrent Jobs = 1
216   Password = " "
217   Messages = Standard
218 }
219 #   By default, this job will back up to disk in /tmp
220 Job {
221   Name = client
222   Type = Backup
223   Client = client-fd
224   FileSet = "Full Set"
225   Schedule = "WeeklyCycle"
226   Storage = File
227   Messages = Standard
228   Pool = Default
229   Full Backup Pool = Full-Pool
230   Incremental Backup Pool = Inc-Pool
231   Differential Backup Pool = Diff-Pool
232   Write Bootstrap = "/home/bacula/working/client.bsr"
233   Priority = 10
234 }
235 # List of files to be backed up
236 FileSet {
237   Name = "Full Set"
238   Include = signature=SHA1 compression=GZIP9 {
239     /
240     /usr
241     /home
242   }
243   Exclude = {
244      /proc /tmp /.journal /.fsck
245   }
246 }
247 Schedule {
248   Name = "WeeklyCycle"
249   Run = Full 1st sun at 1:05
250   Run = Differential 2nd-5th sun at 1:05
251   Run = Incremental mon-sat at 1:05
252 }
253 Client {
254   Name = client-fd
255   Address = client
256   FDPort = 9102
257   Catalog = MyCatalog
258   Password = " "
259   AutoPrune = yes      # Prune expired Jobs/Files
260   Job Retention = 6 months
261   File Retention = 60 days
262 }
263 Storage {
264   Name = File
265   Address = localhost
266   SDPort = 9103
267   Password = " "
268   Device = FileStorage
269   Media Type = File
270 }
271 Catalog {
272   Name = MyCatalog
273   dbname = bacula; user = bacula; password = ""
274 }
275 Pool {
276   Name = Full-Pool
277   Pool Type = Backup
278   Recycle = yes           # automatically recycle Volumes
279   AutoPrune = yes         # Prune expired volumes
280   Volume Retention = 6 months
281   Accept Any Volume = yes # write on any volume in the pool
282   Maximum Volume Jobs = 1
283   Label Format = Full-
284   Maximum Volumes = 6
285 }
286 Pool {
287   Name = Inc-Pool
288   Pool Type = Backup
289   Recycle = yes           # automatically recycle Volumes
290   AutoPrune = yes         # Prune expired volumes
291   Volume Retention = 20 days
292   Accept Any Volume = yes
293   Maximum Volume Jobs = 6
294   Label Format = Inc-
295   Maximum Volumes = 5
296 }
297 Pool {
298   Name = Diff-Pool
299   Pool Type = Backup
300   Recycle = yes
301   AutoPrune = yes
302   Volume Retention = 40 days
303   Accept Any Volume = yes
304   Maximum Volume Jobs = 1
305   Label Format = Diff-
306   Maximum Volumes = 6
307 }
308 Messages {
309   Name = Standard
310   mailcommand = "bsmtp -h mail.domain.com -f \"\(Bacula\) %r\"
311       -s \"Bacula: %t %e of %c %l\" %r"
312   operatorcommand = "bsmtp -h mail.domain.com -f \"\(Bacula\) %r\"
313       -s \"Bacula: Intervention needed for %j\" %r"
314   mail = root@domain.com = all, !skipped
315   operator = root@domain.com = mount
316   console = all, !skipped, !saved
317   append = "/home/bacula/bin/log" = all, !skipped
318 }
319 \end{verbatim}
320 \normalsize
321
322 and the Storage daemon's configuration file is: 
323
324 \footnotesize
325 \begin{verbatim}
326 Storage {               # definition of myself
327   Name = bacula-sd
328   SDPort = 9103       # Director's port
329   WorkingDirectory = "/home/bacula/working"
330   Pid Directory = "/home/bacula/working"
331 }
332 Director {
333   Name = bacula-dir
334   Password = " "
335 }
336 Device {
337   Name = FileStorage
338   Media Type = File
339   Archive Device = /files/bacula
340   LabelMedia = yes;    # lets Bacula label unlabeled media
341   Random Access = Yes;
342   AutomaticMount = yes;   # when device opened, read it
343   RemovableMedia = no;
344   AlwaysOpen = no;
345 }
346 Messages {
347   Name = Standard
348   director = bacula-dir = all
349 }
350 \end{verbatim}
351 \normalsize